总提示:“SqlParameterCollection 仅接受非空的 SqlParameter 类型对象,不接受 String 对象。”
SqlConnection conn = new SqlConnection(Log_in.ljmc);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "hanzi";
SqlParameter sqlpar = new SqlParameter("@myhz", SqlDbType.VarChar,50);
sqlpar.Direction = System.Data.ParameterDirection.Input;
sqlpar.Value = "中华人民共和国";
cmd.Parameters.Add("@myhz");
SqlParameter sqlpar1 = new SqlParameter("@daima", SqlDbType.VarChar, 50);
sqlpar1.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add("@daima");
this.textBox1.Text = cmd.Parameters["@daima"].Value.ToString();
conn.Close();
cmd.Dispose();
}