>***************** >Private Sub Command2_Click() > Dim rsocd As New ADODB.Recordset > Dim oconn As ADODB.Connection > Dim rstemp As New ADODB.Recordset > Dim s As String > Dim maxno As Long > Dim newno As Long > Dim Item2 As String > Dim sql As String > Dim sqlid As String > Dim txtfilename As String > > Dim fso As New FileSystemObject, txtfile, _ > fil1 As File, ts As TextStream > FItem = File1.Path > 'Now the Database connection > mytablepath > Set oconn = New ADODB.Connection > oconn.CursorLocation = adUseClient > oconn.ConnectionString = "Provider=vfpoledb.1;Data Source=\\Myserver\pulic\PMIS.dbc;Collating Sequence=machine" > oconn.Open > oconn.Execute ("set null off") > > 'Now the for Next loop > For i2 = 0 To File1.ListCount - 1 > Set rsocd = Nothing > > rsocd.Open "Select * from ocrdata where ID = (Select max(id) from ocrdata)", oconn, adOpenDynamic, adLockOptimistic, adCmdText > > Item2 = File1.List(i2) > 'Getting new ID > Set rstemp = Nothing > > rstemp.Open "SELECT OCID FROM ocrdataid", oconn, adOpenDynamic, adLockOptimistic, adCmdText > > If IsNull(rstemp!ocid) Then > newno = 1 > Else > maxno = rstemp!ocid > newno = maxno + 1 > End If > 'rstemp.Update > rstemp.Close > Set rstemp = Nothing > > oconn.Execute "update ocrdataid set ocid=" & newno > > 'Now getting the OCR content from text file (Item2) > txtfilename = FItem & "\" & Item2 > Set fil1 = fso.GetFile(txtfilename) > Set ts = fil1.OpenAsTextStream(ForReading) > Do While Not ts.AtEndOfStream > s = ts.ReadAll > Loop > Set fil1 = Nothing > Set fso = Nothing > Set ts = Nothing > > '**********Now the recordset > rsocd.AddNew > rsocd!id = newno > If Item2 <> "" Then > rsocd!tiffile = Trim(Item2) > End If > If s <> "" Then > rsocd!ocdata = Trim(s) > End If > rsocd!created_dt = Date > rsocd.Update > > Item2 = "" > s = "" > rsocd.Close > Set rsocd = Nothing > Next i2 > >End Sub >***************** End of code******************************>From VB i am able to do this: