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..
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..
would it be possible to combine the 2 queries:
or something along those lines?
using the recordset.delete is normally not the most efficient method ...
DELETE applications
WHERE HID in ( SELECT HID FROM othertable WHERE ... )
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
ASKER
Can you explain deeply please..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The answer was perfect
ASKER