我用C#调用带返回值的存储过程 ,总是出错!VB实现了。大家看看代码那里错了!
public SqlConnection mycon=null;
public SqlDataAdapter myda=null;
public DataSet myds=null;
public SqlCommand mycom=null;
public SqlParameter sqlpar=null;
public string str="user id=develop;data source=172.17.1.12;persist security info=True;initial catalog=DbConvert;password=develop";
******************************************************************
mycon=new SqlConnection(@str);
mycom=new SqlCommand(str1,mycon);
mycom.CommandType=CommandType.StoredProcedure ;
sqlpar=new SqlParameter ("@input",SqlDbType.Int);
sqlpar.Direction=System.Data.ParameterDirection.Input;
sqlpar.Value=Convert.ToInt16(this.textBox1.Text);
mycom.Parameters.Add("@input");
SqlParameter sqlpar1=new SqlParameter("@output",SqlDbType.Int,20);
sqlpar1.Direction =System.Data.ParameterDirection.Output;
mycom.Parameters.Add("@output");
mycon.Open();
mycom.ExecuteNonQuery();
mycon.Close();
this.label3.Text=mycom.Parameters["@output"].Value.ToString();
[原创]C# 存储过程