C# C中SQL server的调用存储过程错误

C# C中SQL server的调用存储过程错误,c#,database,sql-server-2005,C#,Database,Sql Server 2005,可能重复: 如何使用C从项目中调用存储过程?我需要将该存储过程的输出放入数据表中,但出现了一个错误 代码: 错误: 这确实是一个应该在谷歌上搜索的东西,但您要查找的一般代码如下所示: string connect = System.Configuration.ConfigurationManager.AppSettings["conn"]; SqlConnection connection = new SqlConnection(connect); string spName =

可能重复:

如何使用C从项目中调用存储过程?我需要将该存储过程的输出放入数据表中,但出现了一个错误

代码:

错误:

这确实是一个应该在谷歌上搜索的东西,但您要查找的一般代码如下所示:

  string connect = System.Configuration.ConfigurationManager.AppSettings["conn"];
  SqlConnection connection = new SqlConnection(connect);
  string spName = "TheSpName";

  SqlCommand spCmd = new SqlCommand(spName, connection);
  spCmd.CommandType = CommandType.StoredProcedure;

  spCmd.Parameters.Add("@SomeParam", SqlDbType.String).Value = "Some Parameter";

  connection.Open();

  var dataTableReader = spCmd.ExecuteReader();

您需要向我们展示您迄今为止所做的尝试。通常,您只需将SqlCommand对象的CommandType属性设置为StoredProcedure。有太多文档,您可以先尝试搜索,然后在遇到问题时返回特定代码/问题。
ERROR : KEYWORD NOT SUPPORTED : 'PROVIDER'
  string connect = System.Configuration.ConfigurationManager.AppSettings["conn"];
  SqlConnection connection = new SqlConnection(connect);
  string spName = "TheSpName";

  SqlCommand spCmd = new SqlCommand(spName, connection);
  spCmd.CommandType = CommandType.StoredProcedure;

  spCmd.Parameters.Add("@SomeParam", SqlDbType.String).Value = "Some Parameter";

  connection.Open();

  var dataTableReader = spCmd.ExecuteReader();