请问:
在C#中如何使用SelectCommand调用存储过程,并将参数传给存储过程

解决方案 »

  1.   

    在数据库里写好存储过程,打开VS.Net,把存储过程从服务器资源管理器拉到窗体上就什么都有了
      

  2.   

    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlConnection1.ConnectionString = "连接字符串";
    this.sqlCommand1.CommandText = "存储过程名";
    this.sqlCommand1.CommandType = System.Data.CommandType.StoredProcedure;
    this.sqlCommand1.Connection = this.sqlConnection1;
    this.sqlCommand1.Parameters.Add("@param1", System.Data.SqlDbType.Varchar, 10) //存储过程有一个参数@param1
    this.sqlConnection1.Open();
    this.sqlCommand1.Parameters["@param1"]="value";//给删除赋值
    this.sqlCommand1.ExecuteNonQuery();//运行存储过程
    this.sqlConnection1.Close();