1
我正在嘗試使用ADO數據集將一條新記錄添加到Visual FoxPro數據表中,但沒有運氣。代碼運行良好,沒有例外,但是當我檢查dbf後沒有新的記錄。代碼片段中顯示的mDataPath變量是整個數據庫的.dbc文件的路徑。關於底部For循環的說明;我將收到的電子郵件的主體添加到此MEMO字段,因此我認爲我需要將此字符串添加到256個字符的塊中。任何指導將不勝感激。使用ADO記錄集將新記錄添加到VB.NET中的VFP數據表中
cnn1.Open("Driver={Microsoft Visual FoxPro Driver};" & _
"SourceType=DBC;" & _
"SourceDB=" & mDataPath & ";Exclusive=No")
Dim RS As ADODB.RecordsetS = New ADODB.Recordset
RS.Open("select * from gennote", cnn1, 1, 3, 1)
RS.AddNew()
'Assign values to the first three fields
RS.Fields("ignnoteid").Value = NextIDI
RS.Fields("cnotetitle").Value = "'" & mail.Subject & "'"
RS.Fields("cfilename").Value = "''"
'Looping through 254 characters at a time and add the data
'to Ado Field buffer
For i As Integer = 1 To Len(memo) Step liChunkSize
liStartAt = i
liWorkString = Mid(mail.Body, liStartAt, liChunkSize)
RS.Fields("mnote").AppendChunk(liWorkString)
Next
'Update the recordset
RS.Update()
RS.Requery()
RS.Close()