问题描述
我前台设计的是一个LinkButton当点击时跳转到新页面(数据添加的页面),息添加完后点击Button确定时显示添加失败!请大家帮我看看我确定按钮里的代码错误在哪里?protectedvoidButton1_Click(objectsender,EventArgse){SqlConnectionmycon=newSqlConnection(ConfigurationManager.AppSettings["conStr"]);mycon.Open();DataSetmydataset=newDataSet();SqlDataAdaptermydataadapter=newSqlDataAdapter("Select*FromAdminLoginWhereAdminID='"+Session["Aid"].ToString()+"'",mycon);mydataadapter.Fill(mydataset,"AdminLogin");DataRowViewrowview=mydataset.Tables["AdminLogin"].DefaultView[0];stringbmp="InsertintoAdminLogin(AdminSex,AdminBirthday,AdminTel,AdminEmail,AdminAddress)"+"values('"+this.DropDownList1.SelectedValue+"','"+this.txtBir.Text+"','"+this.txtTel.Text+"','"+this.txtEmail.Text+"','"+this.txtAddress.Text+"')";SqlDatath=newSqlData();booladd=th.ExceSQL(bmp);if(add==true){Response.Write("<scriptlanguage=javascript>alert('添加成功!');location='AdminFirst.aspx'</script>");}else{Response.Write("<scriptlanguage=javascript>alert('修改失败fsdf!');location='javascript:history.go(-1)'</script>");}}
解决方案
解决方案二:
代碼沒有貼全,沒辦法看啊,初步判斷可能是values前少空格,你單步調試一下就知道了stringbmp="InsertintoAdminLogin(AdminSex,AdminBirthday,AdminTel,AdminEmail,AdminAddress)"+"values('"+this.DropDownList1.SelectedValue+"','"+this.txtBir.Text+"','"+this.txtTel.Text+"','"+this.txtEmail.Text+"','"+this.txtAddress.Text+"')";