tags:

views:

36

answers:

1

hi

i have query (DO2) in access that makes a table and inserting any data.

how to run this query in C# code ?

i try this:

SQL = "Select * from DO2";
        Cmd = new OleDbCommand(SQL, Conn);
        Cmd.ExecuteNonQuery();
        Cmd.Dispose();

but i get error

+1  A: 

If you are running a select query you should be using

OleDbDataReader dr = cmd.ExecuteReader();

instead of ExecuteNonQuery()

and then work with the datareader.

But you mention creating a table and inserting data?

For these you would use ExecuteNonQuery as you have above.

rrrhys