|
-
May 15th, 2003, 02:54 AM
#1
Thread Starter
Junior Member
check if exists... *Resolved*
VB Code:
Dim myConnection As ADODB.Connection
Dim Manu As ADODB.Recordset
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbloc
myConnection.Open
Set Manu = myConnection.Execute("SELECT * FROM installatie WHERE PC_ID LIKE text")
Myconnection.close
manu.close
The above code works fine, but i wan't a query that checks if a record excists... how do i do that?
Thx
Last edited by BroesWillems; May 15th, 2003 at 05:53 AM.
-
May 15th, 2003, 05:16 AM
#2
VB Code:
Dim strSQL As String
strSQL = "SELECT COUNT(*) As Cnt FROM Installatie WHERE PC_ID LIKE 'text%'"
Set Manu = New ADODB.Recordset
Manu.Open strSQL, myConnection
If (Manu("Cnt") > 0) Then
MsgBox "Not empty"
Else
MsgBox "Empty"
End If
' And your clean up code.
-
May 15th, 2003, 05:52 AM
#3
Thread Starter
Junior Member
Originally posted by axion_sa
VB Code:
Dim strSQL As String
strSQL = "SELECT COUNT(*) As Cnt FROM Installatie WHERE PC_ID LIKE 'text%'"
Set Manu = New ADODB.Recordset
Manu.Open strSQL, myConnection
If (Manu("Cnt") > 0) Then
MsgBox "Not empty"
Else
MsgBox "Empty"
End If
' And your clean up code.
Thanks!
-
May 15th, 2003, 06:05 AM
#4
Frenzied Member
If you're planning to use the recordset you could check the recordcount of it.
VB Code:
Dim myConnection As ADODB.Connection
Dim Manu As ADODB.Recordset
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbloc
myConnection.Open
Set Manu = myConnection.Execute("SELECT * FROM installatie WHERE PC_ID LIKE 'text%'")
If Manu.RecordCount > 0 Then
MsgBox "Installatie has " & Manu.Recordcount & " records"
Else
MsgBox "Installatie has no records with PC_ID like text"
End If
Manu.close
Myconnection.close
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|