如何在C#编写储存过程。
  
   请各位帮助小弟。
  谢谢
有分

解决方案 »

  1.   

    存储过程是数据库引擎用SQL语言创建的。
    在C#中用ADO.NET来执行数据库的DDL语句就可以了(登录用户要有相应的权限)。
      

  2.   

    SqlCommand Cmd=new SqlCommand();
    Cmd.CommandText="存储过程名";
    Cmd.CommandType=CommandType.StoredProcedure;
    Cmd.Parameters.Add("@ID",SqlDbType.Int);
    Cmd.Parameters["@ID"].Value=id.Text;
    Cmd.ExecuteNonQuery();
    Cmd.Dispose();
      

  3.   

    大哥,你的标题和内容怎么不一致?调用方法上面几位大大都讲的比较清楚了,你可以在msdn上面查找嘛,里面应该有答案的
      

  4.   


    SqlCommand myCommand = new SqlCommand("GetBankID",Conn);
    myCommand.CommandType = CommandType.StoredProcedure; SqlParameter WP = new SqlParameter("@WP", SqlDbType.VarChar);
     WP.Value = wp;
    myCommand.Parameters.Add(WP);
    SqlParameter BID = new SqlParameter("@BID", SqlDbType.Int);
    BID.Direction=ParameterDirection.Output;
    myCommand.Parameters.Add(BID); SqlParameter ACC = new SqlParameter("@ACC", SqlDbType.VarChar);
    ACC.Direction=ParameterDirection.Output;
    myCommand.Parameters.Add(ACC); myCommand.ExecuteNonQuery();
    bank_id=(int)BID.Value;  
    account=(string)ACC.Value;
      

  5.   

    先创建一个存储过程:pro_a
    cs代码:
    SqlCommand myCommand = new SqlCommand("GetBankID",Conn);
    myCommand.CommandType = CommandType.StoredProcedure;myCommand.CommandText = "exec pro_a";myCommand.ExecuteNonQuery();
      

  6.   

    ArrayList alt = new ArrayList();
    alt.Add("sp_Curflow");//存储过程名
    alt.Add(Flowusercode);//第一参数数值
    alt.Add("@usercode");//第一参数存储过程参数
    alt.Add(4);//第一参数存储过程参数的长度
    try
    {
    System.Data.OleDb.OleDbConnection con= new System.Data.OleDb.OleDbConnection();
    con.ConnectionString = "........";
    con.Open();
    if (con.State == System.Data.ConnectionState.Open)
    {
    System.Data.OleDb.OleDbCommand com = new OleDbCommand(alt[0].ToString(),con);
    com.CommandType = System.Data.CommandType.StoredProcedure;
    //参数定义
    OleDbParameter mp1 = com.Parameters.Add(.......);
    //参数赋值
    mp1.Value = alt[1].ToString();
    com.ExecuteNonQuery();
    con.Close();    
    }
    catch
    {
    throw new CBMaterial.Exception.Exception("ER1004","执行存储过程错误");
    }
      

  7.   

    以前也为写存储过程郁闷过
    http://blog.csdn.net/berlin8600/archive/2005/03/24/329341.aspx
    参考一下吧。