刚刚编辑了此子例程,所以我现在可以保存语言和字体的值。
以前效果很好,但是现在它给了我sql字符串一个语法错误。
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
字段Language
和Font
已添加到表中,并且所有传递的变量均具有有效值。为什么会这样?
这是SQL Server吗?您应该为您的DBMS问题添加标签。但是,由于您提到的问题是在添加这两列之后开始出现的,因此很有可能是列名出现了问题。
在SQL Server中,Language
是保留关键字。请参阅列表:Reserved Keywords (Transact-SQL)。命名对象时,避免使用保留关键字(或过于笼统的关键字)。但是,如果您将列名放在方括号之间(例如[Password]
),则应该可以使用。
我宁愿使用user_language
,user_password
等名称((password
应该是Mysql中的保留关键字)。