诚请各位大侠,求助,回答正确一定给分
为什么实现不了修改的功能数据库名:sanghui_data
表名:USER
字段名:(int主键)ID,(nvarchar)USERNAME,(nvarchar)USERID,(nvarchar)PASSWORD,(nvarchar)USERINFO,(nvarchar)PICTRUE,(varchar)LXR,(varchar)TEL,(varchar)FAX,(varchar)EMALL,(varchar)URL,(varchar)ADDRESS,(varchar)PASSCODE,(int)GRADE,(datetime)REGDATE
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Redact_User : System.Web.UI.Page
{
private static string user = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
user = Request.QueryString["userid"];
}
this.txtUserid.Text = user;
}
DataBase.DBFactory clsDbFac = new DataBase.DBFactory();
//保存修改以后的信息
protected void btnSave_Click(object sender, EventArgs e)
{
string Userid = this.txtUserid.Text;//会员编号
string UserName = this.txtUserName.Text;//会员名称
string Userinfo = this.txtUserinfo.Text;//会员描述
string Lxr = this.txtLxr.Text;//联系人
string Tel = this.txtTel.Text;//电话
string Fax = this.txtFax.Text;//传真
string Emall = this.txtEmall.Text;//Emall地址
string Url = this.txtUrl.Text;//Url地址
string Address = this.txtAddress.Text;//住址
string Passcode = this.txtPasscode.Text;//会员代码
int Grade = Convert.ToInt32(this.ddlGrade.SelectedValue.ToString());//会员级别
//判断会员编号是否存在
string sql = "select count(*) from [USER] where USERID='" + this.txtUserid.Text + "'";
string st = clsDbFac.ExecuteSqlScalar(sql);
int intReturn = Convert.ToInt32(st);
try
{
if (intReturn > 0)
{
string sql1 = "update [USER] set USERNAME='" + UserName + "',USERINFO='" + Userinfo + "',LXR='" + Lxr + "',TEL='" + Tel + "',FAX='" + Fax + "',EMAIL='" + Emall + "',URL='" + Url + "',ADDRESS='" + Address + "',PASSCODE='" + Passcode + "',GRADE=" + Grade + " where USERID='" + Userid + "'";
int i = clsDbFac.ExecuteSqlNonQuery(sql1);
if (i > 0)
{
Response.Write("<script>alert('会员修改成功!');</script>");
}
else
{
Response.Write("<script>alert('会员修改失败!');</script>");
}
}
else
{
Response.Write("<script>alert('会员编号不存在!');</script>");
}
}
catch (Exception ee)
{
Response.Write(ee.Message);
}
}
} --------------------编程问答-------------------- 你自己设个断点走一下嘛,看是走到哪里跳出去了 --------------------编程问答-------------------- 调式一下看看进不进if (intReturn > 0)
--------------------编程问答-------------------- 我设了断点,可是不知道该哪里 --------------------编程问答-------------------- 主要是看它是否存在这个帐户. 断点设置在: int intReturn = Convert.ToInt32(st);
跟踪. --------------------编程问答-------------------- int intReturn = Convert.ToInt32(st); 这里没问题
--------------------编程问答-------------------- 调式慢慢来 我也看不出错误来 细心点总会找到错误
看看赋值 看看强转 试试SQL --------------------编程问答-------------------- 多谢楼上的指导,我自己再调试看看 --------------------编程问答-------------------- GRADE=" + Grade + "
改成
GRADE=" + Grade.ToString() + " --------------------编程问答-------------------- 晕~
if (intReturn > 0)
{
string sql1 = "update [USER] set USERNAME='" + UserName + "',USERINFO='" + Userinfo + "',LXR='" + Lxr + "',TEL='" + Tel + "',FAX='" + Fax + "',EMAIL='" + Emall + "',URL='" + Url + "',ADDRESS='" + Address + "',PASSCODE='" + Passcode + "',GRADE=" + Grade + " where USERID='" + Userid + "'";
如果不存在重复ID号则intReturn=0 --------------------编程问答-------------------- 我刚刚试了一下,楼上的还是不行的 --------------------编程问答-------------------- intReturn > 0改为intReturn=0不是语法错误,是思路错误,
没有重复ID号时才更新啊
当大于零时,说明有重复ID号啊. --------------------编程问答-------------------- 问题不在于楼上所说的 --------------------编程问答-------------------- 我把文件发给你们,你们试着调试一下,,可以吗?
补充:.NET技术 , ASP.NET