Home | Advertising Info75 USERS CURRENTLY ONLINE   
PowerASP

download aspbanner !!
rotate banners on your website !!

   Site Search Contact Us Sunday, March 14, 2010  


Using A Select Statement.



In this example we are selecting a record based on a name that we already have.
We are basically doing a parameterized query.

The SQL statement is the key and by changing that you can search however you want. This is just an example.

<% FULLNAME = "Teddy Gordon" %>

<%
' declaring variables
' not neccesary but a good habit
Dim DataConn
Dim CmdSimpleSelect
Dim MYSQL
   
Set DataConn = Server.CreateObject("ADODB.Connection")
Set CmdSimpleSelect = Server.CreateObject("ADODB.Recordset")
   
' The line below shows how to use a system DSN instead of a DNS-LESS connection
' DataConn.Open "DSN=System_DSN_Name"
DataConn.Open "DBQ=" & Server.Mappath("../_database/database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
   
MYSQL = "SELECT ID, NAME, EMAIL, MESSAGE FROM some_table WHERE (NAME = '" & FULLNAME & "')"
   
CmdSimpleSelect.Open MYSQL, DataConn
%>

<%= CmdSimpleSelect("ID") %><br>
<%= CmdSimpleSelect("NAME") %>
<br>
<%= CmdSimpleSelect("MESSAGE") %>
<br>
<%= CmdSimpleSelect("EMAIL") %>
<br>

<%
' closing objects and setting them to nothing
' not neccesary but a good habit
CmdSimpleSelect.Close
Set CmdSimpleSelect = Nothing
DataConn.Close
Set DataConn = Nothing
%>



   Active Server Pages Rule The World
Contact Us  

Try aspprotect for FREE !!
the premier asp based user management system !!

All artwork, design & content contained in this site are Copyright © 1998 - 2010 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

vbscript active server pages ASP vbscript SQL database informix oracle SQL Server Perl CGI Delphi PHP source code code sample samples program CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com