views:

221

answers:

1

Hi,

In MS Access I have a query wich takes two parameters and I'd like to get the result of this query in a ADO.NET DataSet with a TableAdapter.

In Visual Studio Express 2008 I can't select the query in the assistant. In fact it seems I can't select any queries with parameters. Is there any way to use am Access parameterized query in ADO.NET?

+2  A: 

query1

SELECT * FROM EMP where eno=meno and ename=mename

Popuplate DataTable instance

OleDbConnection cn = new OleDbConnection(@"connect_string");
OleDbCommand cmd = new OleDbCommand("query1", cn);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("meno", OleDbType.Integer, 4, "eno");
cmd.Parameters.Add("mename", OleDbType.VarChar, 40, "ename");
cmd.Parameters[0].Value = 44;
cmd.Parameters[1].Value = "ddd";

OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
adatapost
Hi, thanks for this answer. I did not use your code, but I did all your code do in the DataSet editor and it worked.
Mathieu Pagé