public static void GetStudentById(int studentID) { using (OleDbConnection connection = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Students.mdb;Persist Security Info=True")) { connection.Open(); using (OleDbCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "GetStudentById"; command.Parameters.AddWithValue("@studentID", studentID); OleDbDataAdapter adapter = new OleDbDataAdapter(command); adapter.TableMappings.Add("Table", "Students"); StudentsDataSet dataset = new StudentsDataSet(); adapter.Fill(dataset); DataSetDump.ShowDSInOutputWindow(dataset); } }
Wednesday, May 1, 2013
sql command
How to create a DataView from DataTable?
In order to create a DataView from a DataTable, use instantiate the DataView object by passing DataTable as parameter in the constructor.
eg.
eg.
DataView dView = new DataView(dTable);
Can DataAdapter object accept DataTable as parameter in Fill method?
Yes,
DataAdapter object can accept either DataTable or DataSet as parameter to fill data from database.
eg.
DataAdapter object can accept either DataTable or DataSet as parameter to fill data from database.
eg.
SqlDataAdapter dAd = new SqlDataAdapter(); DataTable dTable = new DataTable(); DataSet dSet = new DataSet(); ---- --- dAd.Fill(dTable); // will also work dAd.Fill(dSet); // will also work
Subscribe to:
Posts (Atom)