Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am having problems with a SQL cal

Status
Not open for further replies.
Jun 26, 2002
58
US
I am having problems with a SQL call. Everytime the program loops i get an error "operation is not allowed when the object is closed". I have to hit "ok" several times, but it looks like everything is working (just the error) as the data is posted to SQL.

<!------- START CODE------->

For i = 1 To lCol_FoundFiles.Count Step 1
On Error Resume Next
Form2.Adodc1.RecordSource = &quot;Insert into Dev(File,ClientID) Values('&quot; & lCol_FoundFiles.Item(i) & &quot;','&quot; & ClientID & &quot;')&quot;
Form2.Adodc1.Refresh
Next i

<!----END CODE---->


Thanks!

mm
 
Why dont you do this?
Go to Menu Project - Refereces and load Microsoft ActiveX Data Object 2.x

Code:
Private Sub Command2_Click()
    Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim j As Integer
    Dim sql, ConStr As String
    
    'U can use the Connection String of you adodb1 control
    ConStr = &quot;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Aplicaciones;Data Source=SERVIDOR4&quot;
    conn.Open ConStr
      
       For j = 1 To lCol_FoundFiles.Count
        'This is a sample values
         sql = &quot;Insert into Dev(File,ClientID) Values('&quot; & lCol_FoundFiles.Item(i) & &quot;','&quot; & ClientID & &quot;')&quot;
    
         Set rs = conn.Execute(sql)
       Next j
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top