一、ASP.Net与Access数据库连接:
<%@ Import Namespace="system.data.oledb" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="System.IO" %>
<%
Dim dbconn as OledbConnection
dbconn = new OledbConnection("provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("XXX.mdb"))
%>
二、ASP.Net与SQL数据库连接:
<%@ Import Namespace="system.data.oledb" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="System.IO" %>
<%
Dim dbconn as OledbConnection
dbconn = new OledbConnection("provider=sqloledb;server=主机名称;initial catalog=数据库名称;user id=XXX;password=XXX;")
%>
建立记录集对象:
<%
Dim i as integer
Dim sql as OledbDataAdapter
Dim ds as new dataset
sql = new OledbDataAdapter("select * from contact",dbconn)
sql.fill (ds,"guest")
%>