简体   繁体   English

如何在ADO.NET中使用MS Access参数化存储过程?

[英]How to use an MS Access parameterized stored procedure in ADO.NET?

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. 在MS Access中,我有一个查询,它有两个参数,我想在带有TableAdapter的ADO.NET数据集中获取此查询的结果。

In Visual Studio Express 2008 I can't select the query in the assistant. 在Visual Studio Express 2008中,我无法在助手中选择查询。 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? 有什么方法可以在ADO.NET中使用Access参数化查询?

query1 QUERY1

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

Popuplate DataTable instance 弹出DataTable实例

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从存储过程中检索标量值(ADO.NET) - How to retrieve scalar value from stored procedure (ADO.NET) 使用Ado.net阅读Access女士 - reading Ms Access using Ado.net 如何制作一个采用XML并使用该XML作为Update +的存储过程,并通过ado.net调用此存储过程? - How to make a Stored Procedure that takes in XML and uses that xml as an Update + call this stored procedure with ado.net? 如何在 ASP.NET Core MVC 中使用 ADO.NET 将参数添加到存储过程? - How can I add parameters to a stored procedure using ADO.NET in ASP.NET Core MVC? 使用ADO.NET的存储过程-字符串或二进制数据将被截断 - Stored procedure with ADO.NET - String or binary data would be truncated 使用ADO.NET连接到SQL Server存储过程 - Connect to SQL Server Stored procedure with ADO.NET Ado.net 会将值或类型传递给存储过程吗? - Will Ado.net pass to a stored procedure just the value or also the type? Oracle存储过程可与ADO.NET一起使用,但与OrmLite一起抛出异常? - Oracle stored procedure works with ADO.NET but with OrmLite throws exception? 从ADO.NET使用自动生成的更新存储过程进行级联更新 - Cascade Update with Autogenerated Update Stored Procedure from ADO.NET 参数化查询ado.net问题 - Parameterized query ado.net issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM