1

Hey guys this is my db : http://prntscr.com/39on8i

I get this error if I try to add something to my users1 table : Unknown Column Nume in 'field list'

This is my VB code :

'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

1 Answer 1

1

It could be that the ID is being seen as reserved (not sure why), but try and put square brackets around it in the field list [id]

Sign up to request clarification or add additional context in comments.

1 Comment

Actually it was a typo, I did discover it now. At mysqlconnection, my database was users, not accounts. I've been messing around with some settings, thanks tho.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.