jzamss Posted February 7, 2004 Posted February 7, 2004 Good Day. I encountered a problem when filling a dataset using the OleDbDataAdapter. The scenario is like this: I created an object say, Record, that has a DataSet member variable in it. The DataSet's Tables and Columns definition are dynamically defined and created based on a XmlSchema. When filling a specific table in the DataSet, the SelectCommand.CommandText and the Parameters are dynamically created before calling the Adapter.Fill method. example sql: SELECT * FROM CUSTOMER WHERE id=@id where : @id = is created as a parameter for the SelectCommand and the Param.Value is set to a known value --------------------------------------------------------------- Error Message: Must declare the variable @id --------------------------------------------------------------- What is strange is that when using SqlConnection and SqlDataAdapter instead of the OleDbConnection and OleDbDataAdapter, the DataSet if properly filled and the program runs without problem. I think the problem is with the OleDbDataAdapter. I'm new to C# and hopefully you can give me some information and guidance. Best Regards... Quote
fadi Posted February 10, 2004 Posted February 10, 2004 statement should be "SELECT * FROM CUSTOMER WHERE id=' " & @id & "' " Quote
Moderators Robby Posted February 20, 2004 Moderators Posted February 20, 2004 @id is a parameter not a variable, you cannot concatinate it with the Select statement. It should be part of the string itself. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.