标题:为什么我在添加信息时,会出现这样个错误:发生类型为System.Web.HttpUnhan ...
取消只看楼主
水晶之恋
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-4-23
 问题点数:0 回复次数:4 
为什么我在添加信息时,会出现这样个错误:发生类型为System.Web.HttpUnhandledExc
为什么我在添加信息时,会出现这样个错误:
发生类型为System.Web.HttpUnhandledException的异常
搜索更多相关主题的帖子: System Web 类型 
2007-05-17 09:10
水晶之恋
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-4-23
得分:0 
private void add_Click(object sender, System.EventArgs e)
{ strsql="insert into users(username,sex,hometown,nation,birth,health,marry,political,address,mobilephone,homephone,email,gra_school,zhuanye,xueli,gra_time,work_time,dep_name,zhiwu,type,constract_time,cancel_time,PicUrl) values ( ";

strsql+="'" + username.Text + "'";
strsql+="'" + sex.SelectedValue + "'";
strsql+="'" + hometown.Text + "'";
strsql+="'" + nation.Text + "'";
strsql+="'" + birth.Text + "'";
strsql+="'" + health.Text + "'";
strsql+="'" + marry.SelectedValue + "'";
strsql+="'" + political.Text + "'";
strsql+="'" + address.Text + "'";
strsql+="'" + mobilephone.Text + "'";
strsql+="'" + homephone.Text + "'";
strsql+="'" + email.Text + "'";
strsql+="'" + gra_school.Text + "'";
strsql+="'" + zhuanye.Text + "'";
strsql+="'" + xueli.SelectedValue + "'";
strsql+="'" + gra_time.Text + "'";
strsql+="'" + work_time.Text + "'";
strsql+="'" + dep_name.SelectedValue + "'";
strsql+="'" + zhiwu.Text + "'";
strsql+="'" + type.SelectedValue + "'";
strsql+="'" + constract_time.Text + "'";
strsql+="'" + cancel_time.Text + "'";
strsql+=url;
strsql+=")";

com=new SqlCommand(strsql,conn);
conn.Open();
com.ExecuteNonQuery();
com.Dispose();
conn.Close();
Response.Write("<script>javascript:alert('添加成功!!!');</script>");
// Response.Redirect("add_person.aspx?users_id=");
}
2007-05-17 09:29
水晶之恋
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-4-23
得分:0 
private void add_Click(object sender, System.EventArgs e)
{
try
{
string strsql;

strsql="insert into users(username,sex,hometown,nation,birth,health,marry,political,address,mobilephone,homephone,email,gra_school,zhuanye,xueli,gra_time,work_time,dep_name,zhiwu,type,constract_time,cancel_time,PicUrl)";
strsql+=" + values( +";

strsql+="'" + username.Text + "'";
strsql+="'" + sex.SelectedValue + "'";
strsql+="'" + hometown.Text + "'";
strsql+="'" + nation.Text + "'";
strsql+="'" + birth.Text + "'";
strsql+="'" + health.Text + "'";
strsql+="'" + marry.SelectedValue + "'";
strsql+="'" + political.Text + "'";
strsql+="'" + address.Text + "'";
strsql+="'" + mobilephone.Text + "'";
strsql+="'" + homephone.Text + "'";
strsql+="'" + email.Text + "'";
strsql+="'" + gra_school.Text + "'";
strsql+="'" + zhuanye.Text + "'";
strsql+="'" + xueli.SelectedValue + "'";
strsql+="'" + gra_time.Text + "'";
strsql+="'" + work_time.Text + "'";
strsql+="'" + dep_name.SelectedValue + "'";
strsql+="'" + zhiwu.Text + "'";
strsql+="'" + type.SelectedValue + "'";
strsql+="'" + constract_time.Text + "'";
strsql+="'" + cancel_time.Text + "'";
strsql+="'" + url + "'";
strsql+=")";
com=new SqlCommand(strsql,conn);
conn.Open();
com.ExecuteNonQuery();

Response.Write("<script>javascript:alert('添加成功!!!');</script>");
Response.Redirect("default.aspx");
}
catch(Exception ee)
{
Response.Write("出现异常错误!");
throw ee;
}

}
com.Dispose();
conn.Close();
}
2007-05-17 09:56
水晶之恋
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-4-23
得分:0 

我加入信息后,就是那个错
sql语句是不是应该改成:

strsql="insert into users(username,sex,hometown,nation,birth,health,marry,political,address,mobilephone,homephone,email,gra_school,zhuanye,xueli,gra_time,work_time,dep_name,zhiwu,type,constract_time,cancel_time,PicUrl)";
strsql+=" + values( +";

strsql+="'" + username.Text + "'";
strsql+=","; //是不是都加入这句
strsql+="'" + sex.SelectedValue + "'";
strsql+="'" + hometown.Text + "'";
strsql+="'" + nation.Text + "'";
strsql+="'" + birth.Text + "'";
strsql+="'" + health.Text + "'";
strsql+="'" + marry.SelectedValue + "'";
strsql+="'" + political.Text + "'";
strsql+="'" + address.Text + "'";

2007-05-17 10:41
水晶之恋
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-4-23
得分:0 
strsql+= username.Text + "',' ";
strsql+= sex.SelectedValue + "') ";
还是用这个清楚点,比
strsql+="'" + username.Text + "',' ";
strsql+= sex.SelectedValue + "',' ";
........
清楚
2007-05-17 11:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-140058-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.095103 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved