Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using SelectCommand from XSD Schema
Message
From
06/02/2007 11:40:10
Bill Oeftering
Mainstreet Computers, Inc.
Belleville, Michigan, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Using SelectCommand from XSD Schema
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01192845
Message ID:
01192845
Views:
154
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
Map
View

Click here to load this message in the networking platform