PDA

View Full Version : VB Custome login screen


bentotzky
09-16-02, 12:42
I am currently creating a username & password login in visual basic, and the user information is stored in SQL 7.0 Server.

I can established the connection from vb to sql connection, but i cannot figure out the proper code when clicking OK button to verify if the user exist in the sql table. Please help!

Here is the code to connect to sql server on form load.

Dim objConn As Connection
Set objConn = New Connection
objConn.Open "Provider=MSDASQL.1;Password=logjam;Persist
Security Info=True;" & _
"User ID=powerseller;Data Source=PowersellerDEV;Initial Catalog=Powerseller"

Here is the code as a recordset.

Dim objRec As Recordset
Set objRec = New ADODB.RecordSet
objRec.Open "SELECT user_code, user_name, user_level from tblusers", objconn, adOpenstatic, adLockOptimistic, acCmdText

Somehow, I got lost on this part. I need to determine that when I input a username & password it will go back to tblusers table and verify if it is a valid username & password before loading the next form, it its invalid it should display a message and loop until a valid username & password is met. You immediate help will be highly appreciated. Thanks.

rnealejr
09-20-02, 19:39
Use select count(*) instead - test for rs(0) = 0; if true loop else load form.