General information
Title:
Using SelectCommand from XSD Schema
Environment versions
Network:
Windows 2003 Server
I've created and XSD schema for a SQL query with some parameters. After assigning the schema to the dataset, how do I progmatically retrieve the SelectCommand from the DataSet in order to fill it ? I know I could duplicate the SQL query used in the schema but that just makes one more place to remember to change. Here's what I have so far:
...
DataSet ds = new DataSet();
ds.ReadXmlSchema("Orders report.xsd");
OleDbConnection oleDbConnection = new OleDbConnection(ConnectionString);
// I want to use the select statement from the tableadapter in the schema!
OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter("select * from orders", oleDbConnection);
// set the params:
oleDbDataAdapter.SelectCommand.Parameters.AddWithValue("@tdstart", this.DateRange.DateFrom.ToShortDateString());
oleDbDataAdapter.SelectCommand.Parameters.AddWithValue("@tdend", this.DateRange.DateThru.ToShortDateString());
// execute the sql
oleDbDataAdapter.Fill(ds);
Thanks
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only