如何从 C# 代码运行 sp?
我是 ADO.net 的新手。 我实际上创建了一个示例数据库和一个示例存储过程。 我对这个概念很陌生。 我不确定如何从 C# Windows 应用程序连接到数据库。 请指导我提供一些帮助或示例来执行相同的操作。
I am new to ADO.net. I actually created a sample database and a sample stored procedure. I am very new to this concept. I am not sure of how to make the connection to the database from a C# windows application. Please guide me with some help or sample to do the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是通常的模式(对于不同的数据库可能有点不同,Sql Server 不要求您在命令文本中指定参数,但 Oracle 需要,并且在 Oracle 中,参数前缀为 : 而不是 @)
This is the usual pattern (it might be a bit different for different databases, Sql Server does not require you to specify the parameters in the command text, but Oracle does, and in Oracle, parameters are prefixed with : not with @)
像这样的事情:
Something like this:
如果使用 SQL Server:
如果没有,则将 Sql 替换为 Ole 并更改连接字符串。
If using SQL Server:
If not then replace Sql with Ole and change the connection string.
这是一个很好的起点 http://support.microsoft.com/kb/310130
Here is a good starting point http://support.microsoft.com/kb/310130
像这样的东西......(假设你将传递一个 Person 对象)
Something like this... (assuming you'll be passing in a Person object)
听起来您正在寻找有关 ADO.NET 的教程。
这是一个关于直接 ADO.NET 的内容。
这是另一个关于 LINQ to SQL。
It sounds like you are looking for a tutorial on ADO.NET.
Here is one about straight ADO.NET.
Here is another one about LINQ to SQL.