Link to home
Start Free TrialLog in
Avatar of Intelops
Intelops

asked on

VB6 wih SQL 2005

if i run this code in vb6 to remove few rows from the SQL2005 database, its entering in to a unstoppable loop. Please help me to resolve this

Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset



conn.Open "Provider = sqloledb;" & "Data Source=10.10.10.1;" & "Initial Catalog=Master;" & "User ID=sa;" & "Password=password;"
rs.Open "select * from applications", conn, adOpenStatic, adLockOptimistic, adCmdText

rs.MoveFirst
Do Until rs.EOF
If rs.Fields(1) = HID Then
rs.Delete

End If
rs.MoveNext
Loop


All other connectivity with the same connection is working fine. While trying to delete this problem occurs..

Avatar of Intelops
Intelops

ASKER

HID value i am getting from other one query..
Avatar of Guy Hengel [angelIII / a3]
would it be possible to combine the 2 queries:

DELETE applications
  WHERE HID in ( SELECT HID FROM othertable WHERE ... ) 

Open in new window


or something along those lines?
using the recordset.delete is normally not the most efficient method ...
open a new command with the ID in place of rs.Delete
Can you explain deeply please..
ASKER CERTIFIED SOLUTION
Avatar of kaminda
kaminda
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The answer was perfect