主题:求助在C#中有关数据库的问题 在线等 加30分
程序写完后编译没有问题,填好数据提交就抱错
异常详细信息: System.Exception: 将截断字符串或二进制数据。
下面是这个程序
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
//con.open();
string sqlstr="";
string uname=this.uname.Value;
string upwd=this.upwd.Value;
string upass=this.upass.Value;
upass=FormsAuthentication.HashPasswordForStoringInConfigFile(upass,"md5");
string email=this.email.Value;
if(this.uname.Value=="" || this.upwd.Value=="" || this.upass.Value=="" || this.email.Value=="")
{
this.Response.Write("<script>alert('请输入正确的信息!');</script>");
}
else
{
sqlstr="insert into G_Users (UserName,PassWord,Pass,email) values('"+uname.ToString()+"','"+upwd.ToString()+"','"+upass.ToString()+"','"+email.ToString()+"')";
DataSet ds=DataLibrary.dataSet(sqlstr);
if(ds.Tables[0].Rows.Count>0)
{
this.Response.Write("<script>alert('添加成功!');window.location.href='usersshow.aspx';</script>");
}
else
{
this.Response.Write("<script>alert('添加失败!');window.location.href='usersadd.aspx';</script>");
}
}
异常详细信息: System.Exception: 将截断字符串或二进制数据。
下面是这个程序
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
//con.open();
string sqlstr="";
string uname=this.uname.Value;
string upwd=this.upwd.Value;
string upass=this.upass.Value;
upass=FormsAuthentication.HashPasswordForStoringInConfigFile(upass,"md5");
string email=this.email.Value;
if(this.uname.Value=="" || this.upwd.Value=="" || this.upass.Value=="" || this.email.Value=="")
{
this.Response.Write("<script>alert('请输入正确的信息!');</script>");
}
else
{
sqlstr="insert into G_Users (UserName,PassWord,Pass,email) values('"+uname.ToString()+"','"+upwd.ToString()+"','"+upass.ToString()+"','"+email.ToString()+"')";
DataSet ds=DataLibrary.dataSet(sqlstr);
if(ds.Tables[0].Rows.Count>0)
{
this.Response.Write("<script>alert('添加成功!');window.location.href='usersshow.aspx';</script>");
}
else
{
this.Response.Write("<script>alert('添加失败!');window.location.href='usersadd.aspx';</script>");
}
}