>>>>>>>如何在.net中调用存储过程>>>>>>

解决方案 »

  1.   

    public DataSet GetCustomersAll(string tablename)
    {
    DataSet myDs=new DataSet();
    myConnection.Open();
    SqlDataAdapter mySda = new SqlDataAdapter();
    SqlCommand myCommand=new SqlCommand("P_CustomersAll",myConnection);
    myCommand.CommandType=CommandType.StoredProcedure;
    mySda.SelectCommand=myCommand;
    mySda.Fill(myDs, tablename);
    myConnection.Close();
    return myDs;
    }
      

  2.   

    SqlCommand myComm=new SqlCommand("存储过程名",myConn);
      

  3.   

    using(SqlDataAdapter custDA = new SqlDataAdapter("存储过程名",连接名))
    {

    custDA.SelectCommand.CommandType = CommandType.StoredProcedure;
    SqlParameter parameter_1=new SqlParameter("@_name", SqlDbType.VarChar, 10);
    parameter_1.Value=值;
    custDA.SelectCommand.Parameters.Add(parameter_1);
    DataSet MYDS=new DataSet();
    custDA.Fill(MYDS,"tables");

    }
      

  4.   

    SqlConnection conn=new SqlConnection(publicDB.strConn);//联接 SqlCommand cmd=new SqlCommand();
    conn.Open();
    cmd.Connection=conn;
    cmd.CommandType=CommandType.StoredProcedure; //说明类型是存储过程
    cmd.CommandText="get_ep";//存储过程名称 SqlParameter sqlp=new SqlParameter();//指定参数
    sqlp=cmd.Parameters.Add("@epname",SqlDbType.NVarChar,20);
    cmd.Parameters["@epname"].Value=par.Text.Trim();//获得值
    DataSet ds=new DataSet();
    try
    {
    da.SelectCommand=cmd;
    da.Fill(ds,"myTable");
    }
    下面就....
      

  5.   

    1.
      custDA.SelectCommand.CommandType = CommandType.StoredProcedure;
    custDA.SelectCommand.Parameters.Add(parameter......
    .......
    custDA.SelectCommand.Parameters("p_name").value=????
    .....
    custDA.SelectCommand.CommandText = StoredProcedurename2.
    更简单,不用定义参数,适用于不传回返回参数;(其它是一样的,也能传回表)selectcommand.commandtext = "exec p_name 参数1,参数2......"
      

  6.   

    string[] values={customid,custompassword,customname,customphone,customaddress,custompost,customfax,customemail,Createtime};
     //调用存储过程     
     callproc.Call(UCallProcedure.UProcedurename.ProcNewCustom,values);