I have a dbf recordset and I need to add new records to it, as I tried "INSERT INTO" statement, I sometimes got an error message as "Selected Collating Sequence not supported by the operating system" and sometimes it's OK. Anyone knows why?


-------

Codes

Option Explicit

Private Sub Command1_Click()

On Error GoTo errhandler
'--------Establish DBF Connection--------
Dim dbfconn As ADODB.Connection
Dim rec As ADODB.Recordset
Set dbfconn = New ADODB.Connection
Set rec = New ADODB.Recordset


'--------Make copy of dbf file--------
Dim SourcePath As String
Dim TargetPath As String
Dim pathstring As String
'SourcePath = pathstring & strSourceFile
'TargetPath = pathstring + strTargetFile
'FileCopy SourcePath, TargetPath
Dim strQuery As String
Dim RecsAffected As Long

With CommonDialog1
.Filter = "dbf file(*.dbf)| *.dbf"
.ShowOpen
End With

Call OpenDBF(GetPath(CommonDialog1.FileName), "", dbfconn)
strQuery = "SELECT * FROM " & GetName(CommonDialog1.FileName) & ".dbf;"
'OPEN RECORDSET
rec.Open strQuery, dbfconn, adOpenDynamic, adLockOptimistic

MsgBox rec.RecordCount

'EDIT
strQuery = "INSERT INTO " & GetName(CommonDialog1.FileName) & ".dbf" & " (RWY_ID) VALUES ('11');"
dbfconn.Execute strQuery, RecsAffected


errhandler:
MsgBox Err.Description
End Sub