Question:
Questions forr VB and SQL!!!!?
bill
2007-01-24 21:06:41 UTC
I know now how to use ADO control for linking SQL to VB. I want to create a log-in for my program, but do not know how to match the data from VB to SQL. I mean, if the user registers his username and password and then log-ins, the program will compare the data form the VB program to the SQL database and if it matches, then the user then can access.

Please help..
Five answers:
Richard H
2007-01-25 12:47:13 UTC
Check out http://www.pscode.com for great sample codes.
Sanama
2007-01-25 05:15:19 UTC
u will have to pull the data from the table in which u r storing the usernames n password.

then using a loop compare each table row with the values entered by the user in the textboxes,,, if it matches any of the row then exit the loop and open the main page, otherwise write a message box code at the end of the loop telling the user tht the login information is incorrect.
anonymous
2007-01-25 06:09:03 UTC
First, you have to search for that particular login id in your SQL table and then once found, compare the password field to the value that the users inputted.



Like,



FIND LoginID IN SQLTable.LoginIDField

IF FOUND THEN Compare PasswordField TO YourInput

IF NOT FOUND THEN Prompt Message
vij
2007-02-01 11:08:11 UTC
hey thts simple..

1.write a query to get all the possible username and passwords

2.using some loopings, do compare every username with the current textbo content..

if it matches, then compare the password box content with the corresponding pwd field in the table

3.thats al.. do wt ever u want based on its result
rongee_59
2007-01-26 18:41:17 UTC
Let's say you have a form called login.asp which has a section that looks like this:

' -------------------------













User ID:

<%

Response.Write ""

%>

Password:






' -------------------------



So the user clicks the Submit button and the form data gets passed to another page called password.asp. In that page, you'll have code that does something like this:

' -------------------------

Dim userid

Dim password

Dim rsTable

Dim strSQL



' Get the variable values from the previous form

userid = request.form("uid")

password = request.form("pwd")

Session("uid") = userid ' save the user id in a session variable



' Open database connection

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "DSN=MyDatabase.dsn"



' Open the table find a record with the user name

strSql = "select password, FirstName, LastName, " & _

"email, [group], upload " & _

"from tblUsers " & _

"where userid='" & userid & "';"



Set rsTable = Server.CreateObject("ADODB.Recordset")

rsTable.open strSQL,adoCon ' Note: adoCon is a database



' If the user id was not found, redirect to invalid.asp page

If rsTable.EOF or rsTable.BOF Then

   Response.Redirect "invalid.asp?e=u"

End If



' UserID Record found. Does password match?

If rsTable("password") <> password Then

   Response.Redirect "invalid.asp?e=p"

End If



' Save any other user info that you need as session variables:

Session("FName") = rsTable("FirstName")

Session("LName") = rsTable("LastName")

Session("email") = rsTable("email")



rsTable.Close



' Redirect back to home page

Response.Redirect "index.asp"

' -------------------------


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...