Home > Software engineering >  Ask a questions about the FROM words grammar mistakes
Ask a questions about the FROM words grammar mistakes

Time:11-14

Want to do cut books of English abstract words do index, but the program has been an error, prompt "FROM clause grammar error"
Want to ask the great spirit should be how to modify? Or other methods can be used?

Option Compare Database

Sub fenci ()

'create instances and the connection with the current database connection
Dim con As ADODB. Connection
The Set con=New ADODB. Connection
Con. Open CurrentProject. Connection

Dim sql1 As String
Dim sql2 As String
Sql1="SELECT bname, Edescription FROM BookInfo;"
Sql2="SELECT keyword, nameindex FROM index;"

'RST representative title + English introduction recordset
'rstkey representative keywords + index record set
Dim RST As ADODB. You
Dim rstkey As ADODB. You
The Set RST=New ADODB. You
The Set rstkey=New ADODB. You
RST. Open sql1, con, adOpenKeyset, adLockOptimistic
Rstkey. Open sql2, con, adOpenKeyset, lines adLockOptimistic 'this is an error

'cnt1 save RST, the number of records in cnt2 save rstkey
the number of records inDim cnt1 As Integer
Dim cnt2 As Integer
Cnt1=CInt (RST) RecordCount)
Cnt2=CInt (rstkey RecordCount)
'MsgBox (cnt1)
'MsgBox (cnt2)

'the participle
For I=0 To CNT
Dim words () As String
Words=VBA. The Split (RST! Edescription, "")
For n=LBound (words) To UBound (words)
For m=0 To cnt2
If rstkey! Keyword (m) & lt;> Words (n) Then
Rstkey. AddNew
Rstkey. Fields (0)=words (n)
Rstkey. Update
If rstkey! Nameindex () & lt;> RST! Edescription Then
Rstkey. AddNew
Rstkey. Fields (1)=RST! Edescription
Rstkey. Update
The Else
Rstkey. MoveNext
End the If
End the If
Next
Next
RST. MoveNext
Next

End Sub

CodePudding user response:

The SQL statement in the semicolon to try

CodePudding user response:

The index is your information table name?
The index is generally SQL reserved word, had better not use
If really, try sql2="SELECT keyword, nameindex FROM [index];"
  •  Tags:  
  • VBA
  • Related