>Cetin,
>I really appreciate your help, you have provided lot of information to my threads.
>how can i use the clear all or release all commands from my VB program.
>this is my code sample: after inserting 256 records to my table it breaks with an run time error message: "too many variables" on this line:
>rsocd.Open "Select * from ocrdata where ID = (Select max(id) from ocrdata)", oconn, adOpenDynamic, adLockOptimistic, adCmdText
>
>Which is inside the for loop:
>********************Code*******************
>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
>
>*******************************************
Raj,
Too much VB for me to understand:)
Select * from ocrdata where ID = (Select max(id) from ocrdata)
and later I see you insert data into RS opened with this. I'd never do that even in pure VFP. What's its purpose? Why not a direct 'insert command' as I previously posted? To me it sounds you don't need rs.addnew at all. Even if you'd use addnew I suggest adLockBatchOptimistic and rs.UpdateBatch.
Cetin