问题描述
每一个即时消息试图使用mysql将新的User_Name插入表中,但我一直收到错误消息我的插入语句下面已经存在该公司名称
MySqlCommand sqlcom = new MySqlCommand(插入t_users(Company_Name,User_Name,Serial_Number,Full_Name,Password,Cell_Number,Email,User_Type,Active,
关键字,签名)VALUE(@ Company_Name,@ User_Name,@ Serial_Number,@ Full_Name,@ Password,@ Cell_Number,@ Email,@ User_Type,@ Active,@ Keyword,@ Signature)
Hallo every one im trying to insert a new User_Name into a table using mysql but I keep getting error That company Name already exsits below is my insert statement
MySqlCommand sqlcom = new MySqlCommand("Insert Into t_users(Company_Name, User_Name,Serial_Number,Full_Name,Password,Cell_Number,Email,User_Type,Active,
Keywords,Signature)VALUE(@Company_Name,@User_Name,@Serial_Number,@Full_Name,@Password,@Cell_Number,@Email,@User_Type,@Active,@Keyword,@Signature)
sqlcom.Parameters.Add("@Company_Name", MySqlDbType.VarChar, 100).Value =CompanyName;
sqlcom.Parameters.Add("@User_Name", MySqlDbType.VarChar, 100).Value = txtInsertUser.Text;
sqlcom.Parameters.Add("@Serial_Number", MySqlDbType.VarChar, 100).Value = txtInsertSerial.Text;
sqlcom.Parameters.Add("@Full_Name", MySqlDbType.VarChar, 100).Value = txtInsertFullName.Text;
sqlcom.Parameters.Add("@Password", MySqlDbType.VarChar, 100).Value = txtInsertPassword.Text;
sqlcom.Parameters.Add("@Cell_Number", MySqlDbType.VarChar, 100).Value = txtInsertCell.Text;
sqlcom.Parameters.Add("@Email", MySqlDbType.VarChar, 100).Value = txtInsertEmail.Text;
sqlcom.Parameters.Add("@ User_Type",MySqlDbType.Bit).Value = chkUsertypeInsert.Checked;
sqlcom.Parameters.Add("@ Active",MySqlDbType.Bit).Value = chkInsertActive.Checked;
sqlcom.Parameters.Add("@ Keyword",MySqlDbType.VarChar,100).Value = txtInsertKeyword.Text;
sqlcom.Parameters.Add("@ Signature",MySqlDbType.VarChar,100).Value = txtInsertSignature.Text;
sqlcom.ExecuteNonQuery();
MySqlDataAdapter da =新的MySqlDataAdapter("select * from T_company",mycon2);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = new DataTable();
da.Fill(dt);
gdvauthors.DataSource = dt;
gdvauthors.DataBind();
我的桌子
具有以下列
公司名称PK
用户名pk
序列号
全名
密码
单元格编号
电子邮件
User_type
活跃
关键字
Signature
sqlcom.Parameters.Add("@User_Type", MySqlDbType.Bit).Value = chkUsertypeInsert.Checked;
sqlcom.Parameters.Add("@Active", MySqlDbType.Bit).Value = chkInsertActive.Checked;
sqlcom.Parameters.Add("@Keyword", MySqlDbType.VarChar, 100).Value = txtInsertKeyword.Text;
sqlcom.Parameters.Add("@Signature", MySqlDbType.VarChar, 100).Value = txtInsertSignature.Text;
sqlcom.ExecuteNonQuery();
MySqlDataAdapter da = new MySqlDataAdapter("select * from T_company", mycon2);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = new DataTable();
da.Fill(dt);
gdvauthors.DataSource = dt;
gdvauthors.DataBind();
my table
has the following columns
Company name PK
User_name pk
Serial_number
Full_Name
Password
Cell_Number
Email
User_type
Active
Keywords
Signature
推荐答案
这篇关于无法将记录插入mysql表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!