Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with CommandBuilder
Message
From
27/11/2004 16:46:40
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00965146
Message ID:
00965147
Views:
11
Gerard,

I suspect you've probably missed a step somewhere. Here's a sample from the docs about using the CommandBuilder;
public static DataSet SelectOleDbSrvRows(string myConnection, string mySelectQuery, string myTableName)
{
   OleDbConnection myConn = new OleDbConnection(myConnection);
   OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
   myDataAdapter.SelectCommand = new OleDbCommand(mySelectQuery, myConn);
   OleDbCommandBuilder cb = new OleDbCommandBuilder(myDataAdapter);

   myConn.Open();

   DataSet ds = new DataSet();
   myDataAdapter.Fill(ds, myTableName);

   //code to modify data in DataSet here

   //Without the OleDbCommandBuilder this line would fail
   myDataAdapter.Update(ds, myTableName);

   myConn.Close();

   return ds;
}
~~Bonnie


>When I use the oAD.Update (Adapter command update) i get the folowing:
> The Data Adapter.Select command parameter needs to be initialised.
>
>I added in a :
>oAD.SelectCommand = "Select * from mytable" but I get an error saying canot assign a string to an adapater....
>
>This is happening in a Save Method of an Object, where I have the commandbuilders Insert,Update and Delete properties set. In a GetDataset method of the object I have following code:
> OleDbDataAdapter oAd = new
> OleDbDataAdapter("SELECT "+this.sFields+
> " FROM "+this.sTableName,oCon);
>which I presume is initializing a 'Select' property ?
>
>I am unclear as to what the error message means . Is there a separate 'Select' property somewhere ?
>
>Regards,
>
>Gerard
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform