请给出比较具体的代码,谢谢了

解决方案 »

  1.   

    使用SqlCommand对象,看下帮助里面有示例代码的
      

  2.   

    string connectionString = "连接字符串";
    using(SqlConnection conn = new SqlConnection(connectionString)) 
    {
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "存储过程";
        cmd.Parameters.Add(参数);
        try
        {
            conn.Open();
            cmd.Execute...
        }
        catch(SqlException ex)
        {
        }
        finally
        {
            conn.Close();
        }
    }
      

  3.   

    跟运行一条select一样,只是把select语句换成运行存储过程的语句exec <存储过程名> <参数>
      

  4.   

    我的一个例子,可以参考一下
    private SqlCommand Command()
    {
    if(Command == null)
    {
    selectCommand = new SqlCommand("存储过程名字",
    connectionstring);

    selectCommand.CommandType = CommandType.StoredProcedure;
    }
    return Command;
    }
    public DataSet Getds()
    {
    if(dsCommand == null)
    {
    throw new System.ObjectDisposedException(GetType().FullName);
    }
    DataSet data = new DataSet(); dsCommand.SelectCommand = Command(); dsCommand.Fill(data,"具体的表名称也可以不填"); return data;
    }