我想把ip地址作为表名,在SQL数据库中创建一张新表,我的代码如下,先判断表是否存在,不存在就创建。在创建这里报语法错误 biaoming代表ip地址
Dim c, d As String
Set rec = New ADODB.Recordset
d = "select * from sys.tables where name='" & biaoming & "'"
rec.Open d, Cnn
If rec.EOF Then
Set rec = New ADODB.Recordset
c = "create table '" & biaoming & "'( UploadTime datetime,[1] int,[2] int,[3] int)"
rec.Open c, Cnn
End If
2 个解决方案
#1
表名不允许有"."吧,不能用数字开头吧
#2
可以的,已经解决了,在ip地址前后加上chr(34)
c = "create table " & Chr(34) & biaoming & Chr(34) & "( UploadTime datetime,[1] int,[2] int,[3] int)"
c = "create table " & Chr(34) & biaoming & Chr(34) & "( UploadTime datetime,[1] int,[2] int,[3] int)"
#1
表名不允许有"."吧,不能用数字开头吧
#2
可以的,已经解决了,在ip地址前后加上chr(34)
c = "create table " & Chr(34) & biaoming & Chr(34) & "( UploadTime datetime,[1] int,[2] int,[3] int)"
c = "create table " & Chr(34) & biaoming & Chr(34) & "( UploadTime datetime,[1] int,[2] int,[3] int)"