|
-
Apr 14th, 2006, 06:28 AM
#1
Thread Starter
Member
Search My Sql
can someone please tell me how i can search a mysql database, what i need is for it to search for the username and password and see if they match in the database, i am completley new to mysql, i have through a example managed to connect to the database and disaply it with this:
VB Code:
Option Explicit
Private cn As New ADODB.Connection
Private rs As New ADODB.Recordset
Private cnString As String
Private sSQL As String
Private Sub cmdExecute_Click()
On Error GoTo ErrHandler
Dim sTable As String
sTable = "phpbb_users"
cnString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & "*****" & ";PORT=3306;" & _
"DATABASE=" & "*******" & ";USER=" & "888888" & ";PASSWORD=" & "*******" & _
";OPTION=3;"
cn.ConnectionString = cnString
cn.Open
If chkQuery.Value <> 1 Then sSQL = "Select * from " & sTable
rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic
Set MSHFlexGrid1.Recordset = rs
Set cn = Nothing
Set rs = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, vbCritical
Resume Next
End Sub
i dont know if this matters but the field headings are username and user_password, any help or a point in the right direction would bre great
-
Apr 14th, 2006, 06:33 AM
#2
Re: Search My Sql
Try this.....
VB Code:
If chkQuery.Value <> 1 Then
sSQL = "Select * from " & sTable & " WHERE username = '" & username & "' AND user_password = '" & password & "'"
rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic
'Now check if user exists
If rs.EOF = True Then
msgbox "User doesn't exist!"
else
Set MSHFlexGrid1.Recordset = rs
end if
Set cn = Nothing
Set rs = Nothing
Exit Sub
-
Apr 14th, 2006, 06:47 AM
#3
Thread Starter
Member
Re: Search My Sql
thanks so much, works great
-
Apr 14th, 2006, 06:51 AM
#4
Re: Search My Sql
Glad to help
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
|