{
try
{
//创建存储过程字符串
string sql="proc_zhuce2";
//创建command对象
SqlCommand command = new SqlCommand(sql, ection);
//设置参数类型
command.CommandType = CommandType.StoredProcedure;
//添加输入
command.Parameters.AddWithValue("@name", textBox3.Text);
command.Parameters.AddWithValue("@img", bytes);
command.Parameters.AddWithValue("@money", Convert.ToInt32(textBox4.Text));
//添加输出参数
SqlParameter p = new SqlParameter("@count", SqlDbType.Int);
p.Direction = ParameterDirection.Output;
command.Parameters.Add(p);
ection.Open();
command.ExecuteNonQuery();
int a=Convert.ToInt32(command.Parameters["@count"].SqlValue.ToString());
if (a == 0)
{
MessageBox.Show("帐号已经存在");
}
else
{
string he = string.Format("你的帐号是{0}", a);
MessageBox.Show(he);
}
textBox1.Text = a.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
调用存储过程
最新推荐文章于 2018-06-15 15:23:12 发布