问题描述
protectedvoidButton2_Click(objectsender,EventArgse){stringname=this.T168.Value;stringa=this.D82.Value;stringb=this.T169.Value;stringc=this.T170.Value;stringd=this.T171.Value;stringee=this.D83.Value;stringf=this.D84.Value;stringg=this.D85.Value;stringh=this.D86.Value;stringdanwei=this.T172.Value;SqlConnectioncon=newSqlConnection("server=localhost;database=xitong;uid=sa;pwd=123");con.Open();stringstr="insertintocanjiazhe(name,a,b,c,d,ee,f,g,h,danwei)values('"+name+"','"+xingbie+"','"+nian+"','"+yue+"','"+ri+"','"+zhiwu+"','"+zhuanc+"','"+xueli+"','"+xuewei+"','"+danwei+"')";SqlCommandcomm=newSqlCommand(str,con);intret=comm.ExecuteNonQuery();con.Close();if(ret>0){Response.Write("<scriptlanguage='javascript'>alert('添加成功!');</script>");Response.Write("<script>history.go(-1);</script>");}else{con.Close();}}
解决方案
解决方案二:
什么问题?说清楚
解决方案三:
这样很容易sql注入
解决方案四:
不要用history.go(-1);这种,应该用location.Href='前一页面.aspx'
解决方案五:
说报什么错?这很难看出来