用VBA于ACCESS中编程报错:INSERT INTO语句的语法错误

一个西文检索数据库,生成索引代码如下:PrivateSubupdateind_Click()DimsqlAsStringDimconnstrAsStringDimconn... 一个西文检索数据库,生成索引代码如下:
Private Sub updateind_Click()
Dim sql As String
Dim connstr As String
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset 'to connect the database

Dim words 'define the variables needed
Dim Ifulltext As String
Dim Idno As Integer
Dim i As Integer
Dim letter As String
Dim ins As String
Dim delete As String

connstr = "Provider=Microsoft.jet.OleDb.4.0;Persist Security Info=false;Data Source=e:\papersTest.mdb"
Set conn = New ADODB.Connection
conn.Open connstr

Set rst = New ADODB.Recordset
sql = "SELECT * FROM papers "
rst.Open sql, conn, adOpenDynamic, adLockOptimistic

rst.MoveFirst
Do While Not rst.EOF
Ifulltext = LCase(rst("fulltext")) 'switch the uppercase into lowercase
Idno = rst("dno")
i = 1

Do While i <= Len(Ifulltext) 'switch all the punctuation marks to blank
letter = Mid(Ifulltext, i, 1)
If Asc(letter) < Asc("a") Or Asc(letter) > Asc("z") Then
Ifulltext = Replace(Ifulltext, letter, " ")
End If
i = i + 1
Loop

i = 0
words = Split(rst.Fields("fulltext")) 'get each word as a string array

Do While i < UBound(words) '- LBound(words) + 1
If words(i) <> "" Then
ins = "INSERT INTO [ind](qword,dno) VALUES (" & Chr$(34) & words(i) & Chr$(34) & "," & dno & ")" 'insert into the ind
DoCmd.SetWarnings False
DoCmd.RunSQL ins
DoCmd.SetWarnings True

End If
i = i + 1
Loop
rst.MoveNext
Loop

rst.close

为避免关键字已经将index全部改为ind了,但是还是报错,为什么啊?谢谢谢谢了~~~~~
展开
 我来答
华夏日长兴
2010-05-14 · TA获得超过9593个赞
知道大有可为答主
回答量:6305
采纳率:85%
帮助的人:3750万
展开全部
ins = "INSERT INTO [ind](qword,dno) VALUES ('" & Chr$(34) & words(i) & Chr$(34) & "','" & dno & "')"
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式