Select command in dataAdapter

 Hi all,

I'm building an application to get data from Access database.

I need only to get one field from the database with a dynamic Where creteria I built.

How can use the select command of the dataAdapter in Visual Studio to get the data.

I write the dynamic select sentence in calles the Fill method of the dataAdapter, I get the exception "No parameter was found".

The select sentence I built : "Select person from tblPersons where ((Name = Dany) and (birthData Between #12/5/2005# And #20/12/2005#));

How can I do that

Regards...  

 



Answer this question

Select command in dataAdapter

  • excalidalf

    Hi Wasim,

    You can pass the SQL Query directly to the contructor of the SqlDataAdaper. Sample below:

    ---------------------------------------------------------------------------------------------------------

    CODE SNIPPET

    ---------------------------------------------------------------------------------------------------------

    SqlConnection conn = new SqlConnection("CONNECTIONSTRING");

    DataSet dsetData = new DataSet();

    SqlDataAdapter adapter = new SqlDataAdapter("Select person from tblPersons where ( ( Name = Dany) and (birthData Between #12/5/2005# And #20/12/2005#) )", conn);

    adapter.Fill(dsetData);

    ---------------------------------------------------------------------------------------------------------

    *CONNECTIONSTRING represents the actual connection string.

    Regards,

    Vikram



  • Select command in dataAdapter