日期:2014-05-18  浏览次数:20993 次

帮忙看看这段代码有问题没
VS环境下一个注册界面的后台
使用RadioButton控件分两种注册身份
经测试发现普通用户注册没问题 医生用户点了注册没反应

后台代码:
C# code
    string connStr = ConfigurationManager.ConnectionStrings["connStr"].ToString();//在配置文件中获得连接字符
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                if (rbtn_zj.Checked)
                {
                    string pass = ClsMD5.Encrypt(txt_pwd.Text, "hongying*wangluo");//密文
                    str = "insert into T_doctors(type,dUserName,dPwd,dpassword,dMail,dTrueName,dGander,dHospital,dHAddress,dDepartment,dMajor,dAbout,dPhone,dProfessional,dLiecense)values(@type,@dUserName,@dPwd,@dpassword,@dMail,@dTrueName,@dGander,@dHospital,@dHAddress,@dDepartment,@dMajor,@dAbout,@dPhone,@dProfessional,@dLiecense)";
                    int result = SqlHelper.ExecuteNonQuery(connStr, CommandType.Text, str, new SqlParameter("@type", rbtn_zj.Text), new SqlParameter("@dUserName", ys_Name.Text), new SqlParameter("@dPwd", ys_pwd.Text), new SqlParameter("@dpassword", pass), new SqlParameter("@dMail", ys_mail.Text), new SqlParameter("@dTureName", true_name.Text), new SqlParameter("@dGander", rdfemal.Text), new SqlParameter("@dHospital", txt_hospital.Text), new SqlParameter("@dHAddress", txt_adress.Text), new SqlParameter("@dDepartment", list_keshi.SelectedValue), new SqlParameter("@dMajor", txt_major.Text), new SqlParameter("@dAbout", txt_jianli.Text), new SqlParameter("@dPhone", txt_photo.Text), new SqlParameter("@dProfessional", list_zhicheng.SelectedValue), new SqlParameter("@dLiecense", FileUpload1.FileName));
                    Response.Write("<script type='text/javascript'>alert('恭喜你,您成功注册了医生用户,点此转到登陆界面>>>');document.location='DengLu.aspx';</script>");
                }
                if (rbtn_pt.Checked)
                {
                    string pass = ClsMD5.Encrypt(txt_pwd.Text, "hongying*wangluo");//密文
                    str = "insert into T_users(type,userName,uPwd,password,uMail)values(@type,@userName,@uPwd,@password,@uMail)";
                    int result = SqlHelper.ExecuteNonQuery(connStr, CommandType.Text, str, new SqlParameter("@type", rbtn_pt.Text), new SqlParameter("@userName", txt_username.Text), new SqlParameter("@uPwd", txt_pwd.Text), new SqlParameter("@password", pass), new SqlParameter("@uMail", txt_mail.Text));
                    Response.Write("<script type='text/javascript'>alert('恭喜你,您成功注册了普通用户,点此转到登陆界面>>>');document.location='DengLu.aspx';</script>");
                    //Response.Redirect("DengLu.aspx");//重定向到登录界面
                }
                
                

            }


------解决方案--------------------
调试吧,看看医生处 ExecuteNonQuery 返回什么,insert语句是否正确插入
------解决方案--------------------
两段SQL字符串命令:
"insert into T_doctors(type,dUserName,dPwd,dpassword,dMail,dTrueName,dGander,dHospital,dHAddress,dDepartment,dMajor,dAbout,dPhone,dProfessional,dLiecense) values(@type,@dUserName,@dPwd,@dpassword,@dMail,@dTrueName,@dGander,@dHospital,@dHAddress,@dDepartment,@dMajor,@dAbout,@dPhone,@dProfessional,@dLiecense)";
你把values前面插入一个空格试试(两段SQL命令都需要加空格),看能不能执行,或者报什么异常错误?
------解决方案--------------------
探讨

引用:

两段SQL字符串命令:
"insert into T_doctors(type,dUserName,dPwd,dpassword,dMail,dTrueName,dGander,dHospital,dHAddress,dDepartment,dMajor,dAbout,dPhone,dProfessional,dLiecense) values(@type,@d……

id"form1"被其他控件使用',解决就50分解决办法