Just edited this subroutine so I can now save a value for language and font.
It worked perfectly fine before, but now it gives me a syntax error with the sql string.
Sub insertuservalues(conn, a, b, c, d, e, f)
Dim sql As String = "INSERT INTO tblUserDetails(Name,Username,[Password],Email,Language,Font) VALUES (@name, @username, @password, @email, @language, @font)"
Using connection As New OleDbConnection(conn)
Using command As New OleDbCommand(sql, connection)
connection.Open()
command.Parameters.Add("@name", OleDbType.VarWChar).Value = a
command.Parameters.Add("@username", OleDbType.VarWChar).Value = b
command.Parameters.Add("@password", OleDbType.VarWChar).Value = c
command.Parameters.Add("@email", OleDbType.VarWChar).Value = d
command.Parameters.Add("@language", OleDbType.VarWChar).Value = e
command.Parameters.Add("@font", OleDbType.VarWChar).Value = f
command.ExecuteNonQuery()
connection.Close()
End Using
End Using
End Sub
Fields Language
and Font
were added to the table, and all the variables passed have a valid value. Why could this be?
Is this SQL Server ? You should add a tag to the question for your DBMS. But since you mention the problem began after adding those two columns it is quite likely the column names are the problem.
In SQL Server Language
is a reserved keyword. See the list: Reserved Keywords (Transact-SQL). Avoid reserved keywords (or overly generic keywords) when naming objects. But if you enclose the column name between brackets (like [Password]
) that should work.
I would rather use names like user_language
, user_password
etc. (password
should be a reserved keyword in Mysql).