Information générale
Titre:
Using SelectCommand from XSD Schema
Versions des environnements
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement