C#与SQL SERVER2000写的程序存储过程的调用方法是怎样的.哪位高手给指点一下

解决方案 »

  1.   

    DataSet dataSet = new DataSet();
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = CreateCommand(procName,null);
    adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
    adapter.Fill(dataSet,tableName);
      

  2.   


    string source="server=127.0.0.1;uid=sa;pwd=xxx;database=ddd";
    SqlConnection sqlconn=new SqlConnection(source);
    sqlconn.Open();
    //
    SqlCommand cmd=new SqlCommand("存储过程的名称",sqlconn);
    //设置cmd对象的类型是调用存储过程
    cmd.CommandType=CommandType.StoredProcedure;
    cmd.Parameters.Add(new SqlParameter("@参数",SqlDbType.NVarChar));
    cmd.Parameters.Add(new SqlParameter("@返回参数",SqlDbType.Int,0,ParameterDirection.Output,false,0,0,"返回参数",DataRowVersion.Default,null));//给参数赋值
    cmd.Parameters["@参数"].Value="abc"; 
    //执行命令
    cmd.ExecuteNonQuery();
    //取返回参数
    x=(int)cmd.Parameters["@GDID"].Value;
      

  3.   

    是否在.net中也是这样调用的啊
    另外头文件什么的要加吗?怎么加
      

  4.   

    SqlCommand command = new SqlCommand();
    command.CommandText = "DeleteMrContact";
    command.CommandType = CommandType.StoredProcedure;
    command.Connection = con; SqlParameter param = new SqlParameter(paramChg(EmpConData.CONID_FIELD),SqlDbType.Int);
    param.Value = conID;
    command.Parameters.Add(param); con.Open();
    int result = command.ExecuteNonQuery();
    con.Close();
    if(result>0)
    {
    return true;
    }
    else
    {
    return false;
    }
      

  5.   

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms;
    using System.Collections;
    public static DataSet ExeStoreProcedureReturnDataSet(string sSpName, ArrayList arParameter)
            {
                try
                {
                    dbCnn.Close();
                    dbCnn.Open();
                    SqlDataAdapter spAdapter = new SqlDataAdapter();
                    SqlCommand spCommand = new SqlCommand(sSpName, dbCnn);
                    spCommand.CommandType = CommandType.StoredProcedure;
                    for (int i = 0; i < arParameter.Count; i++)
                    {
                        spCommand.Parameters.Add(arParameter[i]);
                    }
                    spAdapter.SelectCommand = spCommand;
                    DataSet ds = new DataSet();
                    spAdapter.Fill(ds, "Return");
                    return ds;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "执行存储过程失败");
                    return null;
                }
                finally
                {
                    dbCnn.Close();
                }
            }