Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > [SQL] Returning information as string


Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2008, 02:34 AM
Danny Relic Danny Relic is offline
Centurion
 
Join Date: Feb 2007
Posts: 151
Default [SQL] Returning information as string


Hi there!

I've been working on this all day so far. It is the login information for my program, where the user inputs his/her username and password, and the program will connect to the database and check to see if the username and password match a record in the database.

Here's what I have so far.

Code:
Option Explicit
Public conn As New ADODB.Connection 'Connection to be used to mysql database

Public Function OpenConn(srvIP As String, dbNAme As String, dbUser As String, dbPass As String, dbPORT As Long, statusbox As StatusBar)
    On Error GoTo errH
    
    If conn.State <> 0 Then conn.Close 'Check if currently connected if yes, disconnect.
    
    conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=" & srvIP & ";DATABASE=" & dbNAme & ";" _
                                 & "UID=" & dbUser & ";PWD=" & dbPass & "; PORT=" & dbPORT & "; OPTION=3"
    conn.Open  'open the connection
    
    Exit Function
errH:
    statusbox.SimpleText = "Could not connect to server..."
        
End Function

Private Sub cmdLogIn_Click()
    
    sb.SimpleText = "Connecting to server..."
    
    OpenConn "98.XXX.X.XX", "databasename", "databaseloginusername", "dbpassword", "3306", sb
I don't know how to have it look up the txtusername.Text and txtpassword.Text fields in the database though. I get the connection, but I don't know the rest!

Is there a way to simply query for these two items and if it returns true, change the sb.SimpleText to "Log in details verified!"?
Reply With Quote
  #2  
Old 06-21-2008, 02:36 AM
Danny Relic Danny Relic is offline
Centurion
 
Join Date: Feb 2007
Posts: 151
Default

Code:
conn.Open "SELECT * " & vbCrLf & "FROM `Members`" & vbCrLf & "WHERE `Username:` LIKE CONVERT( _utf8 '" & txtUsername.Text & "'" & vbCrLf & "USING latin1 )" _
        & "USING latin1 )" & vbCrLf & "COLLATE latin1_swedish_ci" & vbCrLf & "AND `Password:` LIKE CONVERT( _utf8 '" & txtPassword.Text & "'" & vbCrLf & _
        "USING latin1 )" & vbCrLf & "COLLATE latin1_swedish_ci" & vbCrLf & "LIMIT 0, 30", conn, adOpenKeyset, adLockOptimistic
That returns an error, so I assume this isn't the proper way to query this.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->