One of known operations we do on the database is searching and matching records that exist in database tables based on specific conditions. For example in login task, we search the USER table using users’ input data which it will be in this case “username” and “password”. In this example we are presenting example to show the content of table USER using select query:
Select name, address, firstname, lastname from user where username='msi'
As you many notice that we added where clause to find a match. To run the previous query on MYSQL we run the following snippet:
Dim myConnection,rs Set myConnection =Server.CreateObject("ADODB.Connection") myConnection.Mode=adModeRead myConnection.ConnectionString = aConnectionString myConnection.Open Set queryResults =Server.CreateObject("ADODB.Recordset") rs.open " Select name, address, firstname, lastname from user where username='msi' ", myConnection
if queryResults.EOF Then Response.Write "User not found" Else Response.Write "User with name " & queryResults ("name") End if Set queryResults = Nothing conn.Close Set myConnection = Nothing