更新时间:2023-02-03 16:15:11
如果我将所有ID都取出来(除了ID),它就会起作用,然后我将它们重新添加到背面,它会停止"Year datetime", _
if i take all them out except ID it works and then i add them on by on back it stops "Year datetime," & _
YEAR
是 Access SQL中的保留字.如果我尝试运行以下代码...
YEAR
is a reserved word in Access SQL. If I try to run the following code ...
Dim connectionString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Users\Public\mdbTest.mdb;"
Using con As New OleDbConnection(connectionString)
con.Open()
Using cmd As New OleDbCommand()
cmd.Connection = con
cmd.CommandText = "CREATE TABLE zzzTest (ID COUNTER, Year INTEGER)"
Try
cmd.ExecuteNonQuery()
Console.WriteLine("Table created.")
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using
con.Close()
End Using
...我明白了
Syntax error in field definition.
但是,如果我将字段名称括在方括号中...
However, if I enclose the field name in square brackets ...
cmd.CommandText = "CREATE TABLE zzzTest (ID COUNTER, [Year] INTEGER)"
...然后我得到
Table created.