|
-
Feb 2nd, 2005, 01:36 PM
#1
Thread Starter
Lively Member
Comparing with a database?
Hi there i have written this connection string (with allot of help as im very new to VB)
Option Explicit
Private WithEvents connConnection As ADODB.Connection
Private WithEvents rsRecordSet As ADODB.Recordset
Dim mblnAddMode As Boolean
Private Sub create_user_Click()
Dim strConnect As String
Dim strProvider As String
Dim strDataSource As String
Dim strDataBaseName As String
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
strDataSource = App.Path
strDataBaseName = "\clockDB.mdb;"
strDataSource = "Data Source=" & strDataSource & _
strDataBaseName
strConnect = strProvider & strDataSource
Set connConnection = New ADODB.Connection
connConnection.CursorLocation = adUseClient
connConnection.Open strConnect
Set rsRecordSet = New ADODB.Recordset
rsRecordSet.CursorType = adOpenStatic
rsRecordSet.CursorLocation = adUseClient
rsRecordSet.LockType = adLockPessimistic
rsRecordSet.Source = "Select * From users"
rsRecordSet.ActiveConnection = connConnection
rsRecordSet.Open
Label6.Caption = strConnect
End Sub
i need in the same cmd button routine to check whether the value of the field new_user.text = any of records in the username column of the users table in my database. (basically checking to see whether the username exists before it can create the new user)
any help would be greatly appreciated
Last edited by golyath; Feb 2nd, 2005 at 02:18 PM.
-
Feb 2nd, 2005, 03:13 PM
#2
New Member
Re: Comparing with a database?
Simple enough. Just use the Find method of your recordset.
rsRecordSet.MoveFirst
rsRecordSet.Find "Username = '" & new_user.text & "'"
The value the user entered is surrounded by single quotes.
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
|