加上:parameters[0].Direction=System.Data.ParameterDirection.Output;

解决方案 »

  1.   

    CREATE proc SpgetmaxT00
    @T00employeeno int output
    as
    select @T00employeeno=MAX(T00employeeno) from t01_employee
       if @T00employeeno is null 
       SET  @T00employeeno = 0
       
    GO
      

  2.   

    System.Data.SqlClient.SqlCommand my=new System.Data.SqlClient.SqlCommand();
    my.CommandType=System.Data.CommandType.StoredProcedure;
    my.CommandText="SpgetmaxT00";
    System.Data.SqlClient.SqlParameter[] newp;
    newp[0].Direction=System.Data.ParameterDirection.Output;
    my.Parameters.Add (newp[0]);
    my.ExecuteNonQuery();
      

  3.   

    string strConn;
    strConn = "DATABASE=APPLE;SERVER=.;UID=sa;PWD=redapple;";
    SqlConnection conn = new SqlConnection(strConn);
    //string strSql= "exec SpgetmaxT00 aaa";
    //SqlDataAdapter da = new SqlDataAdapter(strSql,conn);
    //DataSet ds = new DataSet();
    //da.Fill(ds,"mytable"); 
    conn.Open();  SqlCommand cmd = new SqlCommand();
          cmd.CommandText = "SpgetmaxT00";
    cmd.CommandType =  CommandType.StoredProcedure; 
    cmd.Connection  = conn;

    SqlParameter pr = new SqlParameter("@T00employeeno",System.Data.SqlDbType.Int,10);
    pr.Direction = ParameterDirection.InputOutput;
    pr.Value ="1"; 
    cmd.Parameters.Add(pr);

    cmd.ExecuteNonQuery();
    Response.Write(pr.Value);  
    测试通过了,可感觉你的参数好像不起啥用出。