Total members 11797 |It is currently Sat Sep 21, 2019 1:26 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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:
Code:
Select nameaddressfirstnamelastname 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:
Code:

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


To start a connection please check this article :
asp-asp-net/connect-to-mysql-from-asp-t10129.html

If you are updating a record and want to show the number of updated rows :
Code:

queryResults
.open "update user set password ='msi1' where password ='msi2'", myConnection 
queryResults 
.open "select @@rowcount ", myConnection 
numROS
=queryResults (0).value
Response
.Write " Number of affected  rows : " & numROS





Author:
Mastermind
User avatar Posts: 2707
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Run query and search from ASP
 A simple search page using Google AJAX Search API     -  
 JSP Search Engine     -  
 binary search     -  
 Search engine optimization     -  
 search in a string and replace     -  
 Binary search tree C++     -  
 how we can search in filehandling without using structures a     -  
 search for string in a cell array     -  
 How to save a search fields...in Struts2.0     -  
 Servlets/JSP Website search page example     -  



Topic Tags

ASP Forms






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com