本文介绍了无法将参数值从字符串转换为int32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码是
my code is
protected void btnsubmit_Click(object sender, EventArgs e)
{
try
{
SqlConnection vcon = new SqlConnection(ConfigurationManager.ConnectionStrings["surendra"].ToString());
vcon.Open();
SqlCommand vcmd = new SqlCommand();
vcmd.Connection = vcon;
vcmd.CommandType = CommandType.StoredProcedure;
vcmd.CommandText = "register_sp ";
SqlParameter sp1 = new SqlParameter("@emailid", SqlDbType.VarChar, 100);
sp1.Direction = ParameterDirection.Input;
sp1.Value = Txteid.Text;
vcmd.Parameters.Add(sp1);
SqlParameter sp2 = new SqlParameter("@password", SqlDbType.Int);
sp2.Direction = ParameterDirection.InputOutput;
sp2.Value = Txtpwd.Text;
vcmd.Parameters.Add(sp2);
SqlParameter sp3 = new SqlParameter("@firstname", SqlDbType.VarChar, 100);
sp3.Direction = ParameterDirection.Input;
sp3.Value = txtfname.Text;
vcmd.Parameters.Add(sp3);
SqlParameter sp4 = new SqlParameter("@lastname", SqlDbType.VarChar, 100);
sp4.Direction = ParameterDirection.Input;
sp4.Value = Txtlname.Text;
vcmd.Parameters.Add(sp4);
vcmd.ExecuteNonQuery();
Response.Write("http://www.facebook.com");
vcon.Close();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
我的数据库是
my database is
ALTER procedure [dbo].[register_sp]
@emailid varchar(100),@password int,@firstname varchar(100),@lastname varchar(100)
as
insert into Users(emailid,Password,firstname,lastname) values (@emailid,@password,@firstname,@lastname)
select * from users
推荐答案
这篇关于无法将参数值从字符串转换为int32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!