Runoob Tutorial ArchiveEnglish

ADO Query

ADO Query


We can use SQL to create queries, which allows us to specify only the selected records and fields to view.


Display selected data

We only want to display records in the "Companyname" field of the "Customers" table that start with A:

Instance

<%

set conn=Server.CreateObject("ADODB.Connection")

conn.Provider="Microsoft.Jet.OLEDB.4.0"

conn.Open "c:/webdata/northwind.mdb"

set rs=Server.CreateObject("ADODB.recordset")

sql="SELECT Companyname, Contactname FROM Customers

WHERE CompanyName LIKE 'A%'"

rs.Open sql, conn

%>

  

<%for each x in rs.Fields

  response.write("

  next%>

  

  <%do until rs.EOF%>

  

  <%for each x in rs.Fields%>

      

<%next

rs.MoveNext%>

    

<%loop

rs.close

conn.close%>

")
" & x.name & "
<%Response.Write(x.value)%>

Instance Showcase »


More Instances

Display records where "Companyname" is greater than E
How to display only records in the "Companyname" field of the "Customers" table that are greater than E.

Display only customers from Spain
How to display only customers from Spain in the "Customers" table.

Allow users to select filtering criteria
Allow users to select customers by country