调用存储过程
来源:互联网 发布:儿童注意力训练软件 编辑:程序博客网 时间:2024/06/05 07:02
using (SqlConnection ection = new SqlConnection(connString))
{
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());
}
}
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());
}
}
0 0
- 存储过程调用存储过程
- Ibatis调用存储过程调用存储过程
- Java调用存储过程
- 存储过程调用
- asp调用存储过程!
- Asp调用存储过程
- Java 调用存储过程
- Java 调用存储过程
- asp调用存储过程
- JAVA调用存储过程
- cognos调用存储过程
- asp调用存储过程
- 存储过程调用com
- asp调用存储过程
- ASP调用存储过程
- asp调用存储过程
- WebServices调用存储过程
- WebServices调用存储过程
- 后台读取绑定控件中的TextBox值
- Linux下Tomcat重新启动
- spring 页面跳转不到对应的Controller方法
- Eclipse快捷键 10个最有用的快捷键
- 解析 Java 类和对象的初始化过程
- 调用存储过程
- Perl字符串处理
- 从Delphi开始学Cocos2dx-3.0[11]:持续动作之组合动作
- 多表关联视图
- 清空的回收站还可以恢复文件吗
- 基于嵌入式Linux与S3C2410平台的图像识别与处理
- Esper学习之七:EPL语法(三)
- android 与usb 设备通信(二)
- UML快速入门