« Home « Chủ đề C Shark

Chủ đề : C Shark


Có 20+ tài liệu thuộc chủ đề "C Shark"

Accessing a Database Using Visual Studio .NET

tailieu.vn

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...

Adding Restrictions to DataTable and DataColumn Objects phần 1

tailieu.vn

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...

Adding restrictions to datatable and datacolumn objects phần 2

tailieu.vn

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...

Adding Restrictions to DataTable and DataColumn Objects phần 3

tailieu.vn

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...

Adding, Modifying, and Removing DataRowView Objects from a DataView

tailieu.vn

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...

Adding, Updating, and Deleting Related Rows In this section, you'll learn how to make changes in

tailieu.vn

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,...

An Example of Using the Get* Methods phần 1

tailieu.vn

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...

An Example of Using the Get* Methods phần 2

tailieu.vn

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....

Building a More Complex Application

tailieu.vn

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...

Building Queries Using Enterprise Manager

tailieu.vn

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...

Connecting to Access and Oracle Databases

tailieu.vn

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....

Creating a Command Object Using Visual Studio .NET

tailieu.vn

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...

Creating a Connection Object Using Visual Studio .NET

tailieu.vn

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...

Creating a DataAdapter Object Using Visual Studio .NET

tailieu.vn

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:...

Creating a DataView Using Visual Studio .NET

tailieu.vn

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...

Creating a ForeignKeyConstraint Object

tailieu.vn

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

Creating a Simple ASP.NET Web Application Using VS .NET

tailieu.vn

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...

Creating a Simple Shopping Cart Application

tailieu.vn

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...

Creating a SqlCommand Object

tailieu.vn

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...