Có 20+ tài liệu thuộc chủ đề "sybex - c.sharp database programming"
tailieu.vn Xem trực tuyến Tải xuống
Visual Studio .NET's Server Explorer allows you to use a subset of the features contained in the Databases folder of Enterprise Manager. Specifically, Server Explorer allows you to view, create, and edit databases, database diagrams, tables, views, stored procedures, and user-defined functions. In this section, you'll be introduced to Server Explorer and some of its functionality. As you'll see, Server...
tailieu.vn Xem trực tuyến Tải xuống
Adding Restrictions to DataTable and DataColumn Objects. As you know, a DataSet object is used to store a copy of a subset of the database. For example, you can store a copy of the rows from database tables into a DataSet, with each table represented by a DataTable object. A DataTable stores columns in DataColumn objects.. In addition to storing...
tailieu.vn Xem trực tuyến Tải xuống
isPrimaryKey indicates whether the constraint is a primary key constraint or just a regular unique constraint.. The following example uses the Add() method to add a primary key constraint to the Products DataTable:. myDataSet.Tables["Orders"].Constraints.Add(. "Primary key constraint",. myDataSet.Tables["Orders"].Columns["OrderID". This example does the same thing as the previous example that added the primary key constraint using the PrimaryKey property. Notice the...
tailieu.vn Xem trực tuyến Tải xuống
myDataColumn.ColumnName = OrderID myDataColumn.DataType = System.Int32 myDataColumn.AllowDBNull = False myDataColumn.AutoIncrement = False myDataColumn.AutoIncrementSeed = 0 myDataColumn.AutoIncrementStep = 1 myDataColumn.MaxLength = -1. myDataColumn.ReadOnly = False myDataColumn.Unique = True. myDataColumn.ReadOnly = False myDataColumn.Unique = False. myDataColumn.ColumnName = ProductID myDataColumn.DataType = System.Int32 myDataColumn.AllowDBNull = False myDataColumn.AutoIncrement = False myDataColumn.AutoIncrementSeed = 0 myDataColumn.AutoIncrementStep = 1 myDataColumn.MaxLength = -1. myDataColumn.ColumnName = UnitPrice myDataColumn.DataType = System.Decimal...
tailieu.vn Xem trực tuyến Tải xuống
To add a new DataRowView to a DataView, you call the AddNew() method of your DataView. The AddNew() method returns a DataRowView object that you use to set the column values for the new row.The following example calls the AddNew() method of the customersDV DataView:. DataRowView customerDRV = customersDV.AddNew();. customerDRV.EndEdit();. Notice the use of the EndEdit() method of the customerDRV...
tailieu.vn Xem trực tuyến Tải xuống
As you'll see, you must push changes to the underlying database tables in a specific order. Note You'll find all the code examples shown in this section in the ModifyingRelatedData.cs program.. customersInsertCommand.Parameters.Add("@CustomerID", SqlDbType.NChar,. 5, "CustomerID");. customersInsertCommand.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 40, "CompanyName");. customersUpdateCommand.Parameters.Add("@NewCompanyName", SqlDbType.NVarChar, 40, "CompanyName");. customersUpdateCommand.Parameters.Add("@OldCustomerID", SqlDbType.NChar, 5, "CustomerID");. customersUpdateCommand.Parameters.Add("@OldCompanyName", SqlDbType.NVarChar, 40, "CompanyName");. customersUpdateCommand.Parameters["@OldCustomerID"].SourceVersion = DataRowVersion.Original;. customersUpdateCommand.Parameters["@OldCompanyName"].SourceVersion = DataRowVersion.Original;. customersDeleteCommand.Parameters.Add("@OldCustomerID", SqlDbType.NChar, 5,...
tailieu.vn Xem trực tuyến Tải xuống
An Example of Using the Get* Methods. To figure out which Get* method to use to retrieve a particular SQL Server column type, you use Table 9.4, shown earlier. For example, the ProductID column is a SQL Server int, and looking up that SQL Server type in Table 9.4, you can see you use the GetInt32() method to obtain the...
tailieu.vn Xem trực tuyến Tải xuống
The GetSql* methods and Sql* types are defined in the System.Data.SqlTypes. namespace, and they are specific to SQL Server. In addition, the GetSql* methods are specific to the SqlDataReader class. Using the GetSql* methods and Sql* types helps prevent type conversion errors caused by loss of precision in numeric values.. The GetSql* methods are also faster than their Get* counterparts....
tailieu.vn Xem trực tuyến Tải xuống
The form will also feature a Button control, which when pressed will set the Text property of one of the Label controls to a string containing the user's name, gender, and favorite season. Figure 15.4 shows how your final form will appear.. Figure 15.4: The appearance of the final form Perform the following steps:. Now, add the four Label controls...
tailieu.vn Xem trực tuyến Tải xuống
The CustomerID and CompanyName columns from the Customers table. The OrderID and OrderDate columns from the Orders table. The ProductID and Quantity columns from the Order Details table. To start building the query, select the Customers table in Enterprise Manager from the Tables node of the Databases folder for the Northwind database. This opens the query builder, as shown in...
tailieu.vn Xem trực tuyến Tải xuống
To interact with either of these databases in your program, you use classes from the System.Data.OleDb namespace. You'll learn more about the System.Data.OleDb namespace in Chapter 5, "Overview of the ADO.NET Classes.". Connecting to an Access Database. You connect to an Access database using an OleDbConnection object-rather than a SqlConnection object-with a connection string of the following format:. provider=Microsoft.Jet.OLEDB.4.0;data source=databaseFile....
tailieu.vn Xem trực tuyến Tải xuống
To create a SqlCommand object using Visual Studio .NET (VS .NET), you drag a. SqlCommand object from the Data tab of the Toolbox to your form. Add a SqlConnection object to your project (refer back to the previous chapter to see how to add a SqlConnection object using VS .NET). Drag a SqlCommand object to your form. Figure 8.1 shows...
tailieu.vn Xem trực tuyến Tải xuống
You can also drag an. Figure 7.1 shows a form with a SqlConnection object. Figure 7.1: Creating a SqlConnection object with Visual Studio .NET. Once you've created a SqlConnection object, that object appears in the "tray". You can of course still work with them visually when designing your form.. To set the ConnectionString property that specifies the details of the...
tailieu.vn Xem trực tuyến Tải xuống
When you drag a SqlDataAdapter object to your form, you start the Data Adapter Configuration Wizard, as shown in Figure 10.8.. Figure 10.8: The Data Adapter Configuration Wizard Click the Next button to continue.. Pick your connection to the Northwind database (or create a new connection if you don't have an existing one), as shown in Figure 10.9.. Figure 10.9:...
tailieu.vn Xem trực tuyến Tải xuống
Figure 10.14: The Generate Dataset dialog box. Figure 10.15: The new DataSet object in the tray. Figure 10.16 shows the running form.. Figure 10.16: The running form
tailieu.vn Xem trực tuyến Tải xuống
Creating a DataView Using Visual Studio .NET. In this section, you'll learn how to create a DataView using Visual Studio .NET (VS .NET). You can follow along with the steps described in this section:. Open VS .NET and create a new Windows application named myDataView.. Display Server Explorer, connect to your Northwind database, and drag the Customers table to your...
tailieu.vn Xem trực tuyến Tải xuống
Console.WriteLine("myFKC.AcceptRejectRule = ". myFKC.AcceptRejectRule);. Console.WriteLine("Columns:");. foreach (DataColumn myDataColumn in myFKC.Columns). Console.WriteLine("". Console.WriteLine("myFKC.ConstraintName = ". myFKC.ConstraintName);. Console.WriteLine("myFKC.DeleteRule = ". myFKC.DeleteRule);. Console.WriteLine("RelatedColumns:");. foreach (DataColumn relatedDataColumn in myFKC.RelatedColumns). Console.WriteLine relatedDataColumn);. Console.WriteLine("myFKC.RelatedTable = ". myFKC.RelatedTable);. Console.WriteLine("myFKC.Table = ". myFKC.Table);. Console.WriteLine("myFKC.UpdateRule = ". myFKC.UpdateRule);. myFKC.AcceptRejectRule = None Columns:. myFKC.ConstraintName = ForeignKeyConstraintCustomersOrders myFKC.DeleteRule = Cascade. myFKC.RelatedTable = Customers myFKC.Table = Orders. myFKC.UpdateRule = Cascade
tailieu.vn Xem trực tuyến Tải xuống
Creating a Simple ASP.NET Web Application Using VS .NET. In this section, you'll see how to create a simple ASP.NET Web application that contains a text box and a button using VS .NET. You'll learn how to deploy this application to Microsoft's Internet Information Server (IIS). You'll also see how to run the example Web application from Internet Explorer.. Note...
tailieu.vn Xem trực tuyến Tải xuống
Creating a Simple Shopping Cart Application. In this section, you'll modify your DataGridWebApplication you created earlier to turn it into a simple shopping cart. You'll store the shopping cart in a Session object.. Note As mentioned in the previous section, in a real application you'll probably want to store the shopping cart in the database rather than in a Session...
tailieu.vn Xem trực tuyến Tải xuống
Creating a SqlCommand Object. There are two ways you can create a SqlCommand object:. Creating a SqlCommand Object Using a Constructor. Before you use a SqlCommand object you first need a SqlConnection object, which is used to communicate with a SQL Server database:. Next, you can create a new SqlCommand object using the following statement:. In the next section, you'll...