« Home « Chủ đề sybex - c.sharp database programming

Chủ đề : sybex - c.sharp database programming


Có 80+ tài liệu thuộc chủ đề "sybex - c.sharp database programming"

Reading a Column Value Using Strongly Typed DataSet Classes

tailieu.vn

Reading a Column Value Using Strongly Typed DataSet Classes. A strongly typed DataSet object allows you read a column value using a property with the same name as the column. For example, to read the CustomerID of a column, you can use myDataRow.CustomerID rather than myDataRow["CustomerID". Another feature of a strongly typed DataSet is that when you work with it...

Reading Null Values

tailieu.vn

As you learned in Chapter 2, a column defined as null can store a null value. A null value indicates that the column value is unknown. Let's consider an example of reading a null value from the database. performed a SELECT statement that retrieves the UnitPrice column for a row from the Products table, and that the UnitPrice column contains...

Reading Rows from a SqlDataReader Object

tailieu.vn

You can read an individual column value in a row from a DataReader by passing the name of the column in square brackets. You can also specify the column you want to get by passing a numeric value in brackets. The first code snippet uses the column names to read the column values:. while (productsSqlDataReader.Read. Console.WriteLine(productsSqlDataReader["ProductID"]);. Console.WriteLine(productsSqlDataReader["ProductName"]);. Console.WriteLine(productsSqlDataReader["UnitPrice"]);. Console.WriteLine(productsSqlDataReader["Discontinued"]);. The...

Retrieving New Identity Column Values

tailieu.vn

The ProductID column of the Products table is an identity column. In this section, you'll see how to insert a new row into to Products table and retrieve the new value generated by the database for the ProductID identity column.. Note You'll find a complete program named UsingIdentityColumn.cs in the ch11. In the examples, assume you have a DataTable named...

Returning Strongly Typed Column Values

tailieu.vn

Up to this point, you've retrieved column values from a DataReader only as generic objects of the System.Object class (such objects are often referred to as being of the C#. Note All classes in C# are derived from the System.Object class.. I'll rewrite the while loop shown in the example in the previous section to show how you store column...

Setting a Savepoint

tailieu.vn

This might be useful if you have a very long transaction because if you make a mistake after you've set a savepoint, you don't have to roll back the transaction all the way to the start.. Inserts a row into the Customers table with a CustomerID of J8COM.. Sets a savepoint.. Inserts a row into the Orders table with a...

Setting the Transaction Isolation Level

tailieu.vn

Setting the Transaction Isolation Level. The transaction isolation level is the degree to which the changes made by one. Before I get into the details of the various transaction isolation levels, you need to understand the types of problems that might occur when current transactions attempt to access the same rows in a table. Dirty reads Transaction 1 updates a...

Supplying Parameters to Commands

tailieu.vn

Supplying Parameters to Commands. In the examples you've seen up to this point, the values for each column have been hard- coded in the SQL statements. For example, in Listing 8.9, shown earlier, the INSERT statement that added the row to the Customers table was:. As you can see, the values for the CustomerID and CompanyName columns are hard- coded...

The DataColumn Class

tailieu.vn

The DataColumn Class. You use an object of the DataColumn class to represent a column. Table 11.6 shows some of the DataColumn properties.. AllowDBNull bool Gets or sets a bool value that indicates whether null values are allowed in this DataColumn object. The default is true.. AutoIncrement bool Gets or sets a bool value that indicates whether the DataColumn object...

The DataRow Class

tailieu.vn

The DataRow Class. You use an object of the DataRow class to represent a row. Table 11.4 shows some of the DataRow properties.. HasErrors bool Returns a bool value that indicates whether any of the DataColumn objects in the DataRow have errors.. ItemArray object[] Gets or sets all the DataColumn objects in the DataRow.. RowState DataRowState Gets the current state...

The DataRowView Class

tailieu.vn

The DataRowView Class. Rows in a DataView object are stored as objects of the DataRowView class. Table 13.4 shows some of the DataRowView properties, and Table 13.5 shows some of the DataRowView methods.. DataView DataView Gets the DataView that the DataRowView belongs to.. IsEdit bool Gets a bool that indicates whether the DataRowView (and therefore the underlying DataRow) is in...

The DataSet Class

tailieu.vn

The DataSet Class. You use an object of the DataSet class to represent a local copy of the information stored in the database. Figure 10.1 shows the DataSet and its relationship to some of the objects you can store within it. Figure 10.1: Some of the DataSet objects. Table 10.4 shows some of the DataSet properties.. Table 10.4: DataSet PROPERTIES....

The DataSet Class phần 2

tailieu.vn

You can read the Products DataTable from myDataSet using the following example:. DataTable myDataTable = myDataSet.Tables["Products"];. You can also read the Products DataTable using an int value:. DataTable myDataTable = myDataSet.Tables[0];. You can display the column values for each row in myDataTable using the following foreach loop that iterates over the DataRow objects stored in myDataTable. notice the use of...

The DataSet Class phần 3

tailieu.vn

Reading from the Products DataTable ProductID = 1. Reading from the Customers DataTable CustomerID = ALFKI. First, the following code populates a DataSet with a DataTable containing two rows from the Products table:. mySqlCommand.CommandText. mySqlDataAdapter.SelectCommand = mySqlCommand;. int numberOfRows = mySqlDataAdapter.Fill(myDataSet, "Products");. Next, the CommandText property for the SelectCommand of mySqlDataAdapter is changed to a SELECT statement that retrieves rows...

The DataTable Class

tailieu.vn

The DataTable Class. You use an object of the DataTable class to represent a table. Table 11.1 shows some of the DataTable properties.. DataColumn objects that represent the columns in the DataTable object.. (UniqueConstraint) or foreign key constraints (ForeignKeyConstraint) in the DataTable object.. DataSet DataSet Gets the DataSet to which the DataTable belongs.. HasErrors bool Returns a bool value that...

The DataViewManager Class

tailieu.vn

The DataViewManager Class. A DataViewManager allows you to centrally manage multiple DataView objects in a DataSet. A DataViewManager also allows you to create DataView objects on the fly at runtime. Table 13.6 shows some of the DataViewManager properties.. Table 13.6: DataViewManager PROPERTIES. DataSet DataSet Gets or sets the DataSet used by your DataViewManager.. DataViewSettings DataViewSettingCollection Gets the DataViewSettingCollection for each...

The ForeignKeyConstraint Class

tailieu.vn

The members of the. Cascade, which indicates that the changes to the DataRow objects in the parent DataTable are also made in the child DataTable.. DeleteRule Rule Gets or sets the Rule that indicates the action that is to take place when a DataRow in the parent DataTable is deleted.. Cascade, which indicates that the delete or update to the...

The Managed Provider and Generic Data Set Classes

tailieu.vn

The Managed Provider and Generic Data Set Classes. To provide both connected and disconnected database access, ADO.NET defines two sets of classes: managed provider and generic data.. You use objects of the managed provider classes to directly connect to a database and to synchronize your locally stored data with the database. You can use the managed. provider classes to read...

The SqlCommand Class

tailieu.vn

The SqlCommand Class. You use an object of the SqlCommand class to execute a command against a SQL Server database, an object of the OleDbCommand class to execute a command against any database that supports OLE DB, such as Oracle or Access, and an object of the. OdbcCommand class to execute a command against any database that supports ODBC.. Table...

The SqlDataAdapter Class

tailieu.vn

The SqlDataAdapter Class. You use an object of the SqlDataAdapter class to synchronize data stored in a DataSet object with a SQL Server database. You use an object of the OleDbDataAdapter class to synchronize data with a database that supports OLE DB, such as Oracle or Access. You use an object of the OdbcDataAdapter class to synchronize data with a...