Databases Reference
In-Depth Information
Implement this as OdbcDataReader in DB2 ODBC Data Provider, for
example:
OdbcDataReader reader = cmd.ExecuteReader();
The DataReader object has FieldCount and HasRows public properties. The
FieldCount property returns the total number of columns in the current row while
HasRows property indicates whether DataReader has one or more rows by
returning true or false , for example:
int cols=reader.FieldCount;
bool rows=reader.HasRows;
The DataReader object has the following public methods:
Read : Reads in records one row at a time and advances the cursor to the
next row. It returns true or false to indicate whether there are any rows to
read, for example:
bool done=reader.read();
Close : This closes the DataReader, for example:
reader.Close();
Get xxxx : This is used to get data of type xxxx , for example:
Console.WriteLine (reader.GetString(1));
DataSet
The DataSet object represents an “In-memory cache of data”, which was
retrieved from the database. The DataSet object is a disconnected dataset,
which provides a consistent relational programming model independent of the
data source. Since it is disconnected from the database, it reduces the
communication overhead to the database server.
The DataSet object has the public property DataSetName, which gets or sets
DataSet name, for example:
DataSet ds = new DataSet();
ds.DataSetName = "DB2";
The DataSet object has the following public methods:
AcceptChanges : This commits changes to the DataSet, for example:
ds.AcceptChanges();
Clear : This clears the DataSet contents, for example:
ds.Clear();
Search WWH ::




Custom Search