Parameters
- row
- Row to read out.
static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) { myDataTable.Connection = myConnection; myDataTable.SelectCommand = myConnection.CreateCommand(); myDataTable.SelectCommand.CommandText = "SELECT DEPTNO FROM Test.Dept"; System.Data.DataColumn column_DEPTNO = new System.Data.DataColumn(); System.Data.DataColumn column_DNAME = new System.Data.DataColumn(); System.Data.DataColumn column_LOC = new System.Data.DataColumn(); column_DEPTNO.ColumnName = "DEPTNO"; column_DEPTNO.DataType = typeof(int); column_LOC.ColumnName = "LOC"; column_DEPTNO.DataType = typeof(string); myDataTable.Columns.AddRange(new System.Data.DataColumn[] {column_DEPTNO, column_DNAME, column_LOC}); myDataTable.FetchAll = true; myDataTable.Open(); Console.Write("DEPTNO column is loaded"); myDataTable.ReadComplete(myDataTable.Rows[0]); Console.Write("DEPTNO and LOC columns are loaded"); }
Private Shared Sub UseDataTable(ByVal myDataTable As DbDataTable, ByVal myConnection As DbConnection) myDataTable.Connection = myConnection myDataTable.SelectCommand = myConnection.CreateCommand myDataTable.SelectCommand.CommandText = "SELECT DEPTNO FROM Test.Dept" Dim column1 As New DataColumn Dim column2 As New DataColumn Dim column3 As New DataColumn column1.ColumnName = "DEPTNO" column1.DataType = GetType(Integer) column3.ColumnName = "LOC" column1.DataType = GetType(String) myDataTable.Columns.AddRange(New DataColumn() {column1, column2, column3}) myDataTable.FetchAll = True myDataTable.Open() Console.Write("DEPTNO column is loaded") myDataTable.ReadComplete(myDataTable.Rows.Item(0)) Console.Write("DEPTNO and LOC columns are loaded") End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2