Hai,
I was wondering if you guys have a "short-cut" or "simplest easiest way" on how to connect to the database and declare the recordset!
Typically, people will do like this:
- Code: Select all
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
%>
<body>
..
..
</body>
<%
rs.close
conn.close
%>
or maybe some thing like this:
External Connection:
- Code: Select all
<%
Dim MM_connInvoice_STRING
MM_connInvoice_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../db/product.mdb")
%>
index.asp
- Code: Select all
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/connInvoice.asp" -->
<%
Dim rsCustomers
Dim rsCustomers_cmd
Dim rsCustomers_numRows
Set rsCustomers_cmd = Server.CreateObject ("ADODB.Command")
rsCustomers_cmd.ActiveConnection = MM_connInvoice_STRING
rsCustomers_cmd.CommandText = "SELECT * FROM tblCustomer ORDER BY CName ASC"
rsCustomers_cmd.Prepared = true
Set rsCustomers = rsCustomers_cmd.Execute
rsCustomers_numRows = 0
%>
Thanks..