Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using SelectCommand from XSD Schema
Message
De
06/02/2007 11:40:10
Bill Oeftering
Mainstreet Computers, Inc.
Belleville, Michigan, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Using SelectCommand from XSD Schema
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01192845
Message ID:
01192845
Vues:
152
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
Fil
Voir

Click here to load this message in the networking platform