Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create DataSet from SqlSelect with parameter?
Message
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01272138
Message ID:
01272161
Views:
21
>I have created data reader with parameters many times but now I need to create a dataset and I am lost.
>
>Here is an example:
>
>
>OleDbConnection oDbConnection = new OleDbConnection
>(connectionString);
>
>string strSqlCommand = "select * MYTABLE where MYFIELD(?)";
>
>OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSqlCommand,
>oDbConnection);
>
>DataSet dsMyTable = new DataSet();
>
>objAdapter.Fill(dsMyTable, "tblMyTable");
>
>
>
>Somewhere above I have to specify parameter for field MYFIELD but I don't know how and where.
>
>Thank you in advance for any help.


I found out that I probably need to add the parameret to the Adapter object, as following:
objAdapter.GetFillParameters()[0].Value = nMyValue;
But I get an error on this line that index is invalid. So I think I need to find a way to specify that the adapter takes so many paramenters. I can't find how to do it so far.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform