I've been having problem importing another data from another table in-order to create a new record of log-in
ConnectToDB()
sql = "insert into monitoring (id_num, fname, lname, status, floor_level) VALUES (@num),(@name),(@lname),(@stat),(@lev)"
cmd = New MySqlCommand(sql, cn)
With cmd
.Parameters.AddWithValue("@name", TextBox2.Text)
.Parameters.AddWithValue("@lname", TextBox3.Text)
.Parameters.AddWithValue("@stat", TextBox5.Text)
.Parameters.AddWithValue("@lev", lev)
.ExecuteNonQuery()
End With
This is what I tried yet I keep getting a SQL error
and now this is what I kept getting after I fixed my SQL syntax enter image description here It says An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll Additional information: Column count doesn't match value count at row 1 however if I count my database column it is fit and same amount in my query
CodePudding user response:
Your query for value must be like this
sql = "insert into monitoring (id_num, fname, lname, status, floor_level) VALUES (@num, @name, @lname, @stat, @lev)"
CodePudding user response:
wrong sql syntax itt must be sql = "insert into monitoring (id_num, fname, lname, status, floor_level) VALUES (@num, @name, @lname, @stat, @lev)"