用户ID已存在.请选择ID [英] User ID Already Exists. Please, Choose ID
本文介绍了用户ID已存在.请选择ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
虽然我输入了我发现的这个错误的员工注册详细信息,请检查下面的代码并进行更正,
用户ID已存在.请选择ID
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用使用System.Web.UI.WebControls;
使用 System.Data.SqlClient;
使用 System.Data;
使用使用System.Drawing;
公共 部分 类 temp_index:System.Web .UI.页面
{
EmployeeDB empDB;
受保护的 无效 Page_Load(对象发件人,EventArgs e)
{
如果(System.Convert.ToString(Session [" ])!= ")
{}
其他 {Response.Redirect(" ); }
txtfname.Focus();
btnSubmit.Attributes.Add(" ," 返回validate()");
}
受保护的 无效 btnReset_Click(对象发件人,EventArgs e)
{
txtfname.Text = " ;
txtmname.Text = " ;
txtlname.Text = " ;
ddldd.Text = " ;
ddlmm.Text = " ;
ddlyyyy.Text = " ;
ddlgender.Text = " ;
txtaddress.Text = " ;
txtmobile.Text = " ;
txtphone.Text = " ;
txtusername.Text = " ;
txtpwd.Text = " ;
txtsalary.Text = " ;
txtfname.Focus();
lblmsg.Visible = false ;
}
受保护的 无效 btnSubmit_Click(对象发件人,EventArgs e)
{
尝试
{
字符串 dob = ddlmm.Text + " + ddldd.Text + " + ddlyyyy.Text;
empDB = 新 EmployeeDB();
int 成功= 0 ;
成功= empDB.AddNewEmployee(txtfname.Text.Trim(),txtmname.Text.Trim(),txtlname.Text.Trim(),dob,ddlgender.Text,txtaddress.Text.Trim(),txtmobile.Text.Trim( ),txtphone.Text.Trim(),txtusername.Text.Trim(),txtpwd.Text.Trim(),txtsalary.Text.Trim());
lblmsg.Visible = true ;
lblmsg.ForeColor =颜色.绿色;
如果(成功> 0 )
lblmsg.Text = " ;
其他
lblmsg.ForeColor =颜色.红色;
// lblmsg.Text =发生错误!";
}
捕获(例外)
{
lblmsg.ForeColor =颜色.红色;
lblmsg.Text = ex.ToString();
}
}
受保护的 无效 LinkButton2_Click(对象发件人,EventArgs e)
{
Response.Redirect(" );
}
}
解决方案
在下面一行中插入中断并调试plz,
我认为此功能具有代码!!!
成功= empDB.AddNewEmployee(txtfname.Text.Trim(),txtmname.Text.Trim(),txtlname.Text.Trim(),dob,ddlgender.Text,txtaddress.Text.Trim( ),txtmobile.Text.Trim(),txtphone.Text.Trim(),txtusername.Text.Trim(),txtpwd.Text.Trim(),txtsalary.Text.Trim());
您可以通过从表中删除主键或为每个员工记录创建唯一的用户ID来轻松解决此错误.
如果可以发布empDB.AddNewEmployee函数代码,我们可以轻松找出根本原因.
谢谢!!!
While i enter the details for employee registration this error mas i found, please check the below code and make the correction please,
User ID Already Exists. Please, Choose ID
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
public partial class temp_index : System.Web.UI.Page
{
EmployeeDB empDB;
protected void Page_Load(object sender, EventArgs e)
{
if (System.Convert.ToString(Session["un"]) != "")
{ }
else { Response.Redirect("HomePage.aspx"); }
txtfname.Focus();
btnSubmit.Attributes.Add("onclick", "return validate()");
}
protected void btnReset_Click(object sender, EventArgs e)
{
txtfname.Text = "";
txtmname.Text = "";
txtlname.Text = "";
ddldd.Text = "DD";
ddlmm.Text = "MM";
ddlyyyy.Text = "YYYY";
ddlgender.Text = "Select";
txtaddress.Text = "";
txtmobile.Text = "";
txtphone.Text = "";
txtusername.Text = "";
txtpwd.Text = "";
txtsalary.Text = "";
txtfname.Focus();
lblmsg.Visible = false;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string dob = ddlmm.Text + "/" + ddldd.Text + "/" + ddlyyyy.Text;
empDB = new EmployeeDB();
int success = 0;
success = empDB.AddNewEmployee(txtfname.Text.Trim(), txtmname.Text.Trim(), txtlname.Text.Trim(), dob, ddlgender.Text, txtaddress.Text.Trim(), txtmobile.Text.Trim(), txtphone.Text.Trim(), txtusername.Text.Trim(), txtpwd.Text.Trim(),txtsalary.Text.Trim());
lblmsg.Visible = true;
lblmsg.ForeColor = Color.Green;
if (success > 0)
lblmsg.Text = "Employee Registration Saved Succesfully !!";
else
lblmsg.ForeColor = Color.Red;
//lblmsg.Text = "Error Occured !!";
}
catch (Exception ex)
{
lblmsg.ForeColor = Color.Red;
lblmsg.Text = ex.ToString();
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect("AdminHomePage.aspx");
}
}
解决方案
put break in the below line and debug plz,
I think this function have the code!!!!
success = empDB.AddNewEmployee(txtfname.Text.Trim(), txtmname.Text.Trim(), txtlname.Text.Trim(), dob, ddlgender.Text, txtaddress.Text.Trim(), txtmobile.Text.Trim(), txtphone.Text.Trim(), txtusername.Text.Trim(), txtpwd.Text.Trim(),txtsalary.Text.Trim());
Hi,
You can easily fix this error by removing primary key from the table or create a unique user id for each employee record.
If you can post empDB.AddNewEmployee function code we can easily figure out the root cause.
Thanks!!!
这篇关于用户ID已存在.请选择ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文