嘿伙计这是我的数据库: http://prntscr.com/39on8i
如果我尝试向users1表添加内容,则会出现此错误: “字段列表”中的未知列数
这是我的VB代码:
'INSERT INTO config(id,customer_id,domain) 'SELECT DISTINCT id,customer_id,domain FROM config;'
Try
' Dim SqlQuery As String = "INSERT INTO presence(id_presence,id,hours,date) " & _
' "SELECT DISTINCT @Id_presence,@Id,@Hours,@Date FROM presence"
'adding a new user
Dim SqlQuery As String = "INSERT INTO users1(id,Nume,Prenume,username,password,onedrive,access, id_dep, id_pontaj) " & _
"VALUES (0,@Nume,@Prenume,@Username,@Password,@Onedrive,@Access,@Iddep,@Idpontaj)"
Using con = New MySqlConnection("Server = localhost;Database = accounts; Uid=root; Pwd = password")
Using SQLcmd = New MySqlCommand(SqlQuery, con)
con.Open()
'SQLcmd.ExecuteNonQuery()
'SQLcmd.Parameters.AddWithValue("@Id_presence", Convert.ToInt32(TextBox1.Text))
'SQLcmd.Parameters.AddWithValue("@Id", Convert.ToInt32(TextBox2.Text))
'SQLcmd.Parameters.AddWithValue("@Hours", Convert.ToInt32(TextBox3.Text))
'SQLcmd.Parameters.AddWithValue("@Date", Convert.ToDateTime(TextBox4.Text))
SQLcmd.Parameters.AddWithValue("@Nume", Convert.ToString(TextBox2.Text))
SQLcmd.Parameters.AddWithValue("@Prenume", Convert.ToString(TextBox3.Text))
SQLcmd.Parameters.AddWithValue("@Username", Convert.ToString(TextBox4.Text))
SQLcmd.Parameters.AddWithValue("@Password", Convert.ToString(TextBox5.Text))
SQLcmd.Parameters.AddWithValue("@Onedrive", Convert.ToString(TextBox6.Text))
SQLcmd.Parameters.AddWithValue("@Access", Convert.ToInt32(TextBox1.Text))
SQLcmd.Parameters.AddWithValue("@Iddep", Convert.ToInt32(TextBox7.Text))
SQLcmd.Parameters.AddWithValue("@Idpontaj", Convert.ToString(TextBox8.Text))
SQLcmd.ExecuteNonQuery()
End Using
End Using
Catch ex As Exception
MsgBox(" Failure to communicate " & vbCrLf & vbCrLf & ex.Message)
End Try
答案 0 :(得分:1)
可能是ID被视为保留(不确定原因),但尝试在字段列表中放置方括号[id]