web 2.0

How to use ASP & Access Connect to Database

How to use ASP & Access Connect to Database This is tutorial  asp developers how to using asp connect to Microsoft Access database.

ShotDev Focus:
- ASP & Microsoft Access (Connect to Database)

Example

asp_access_connect.asp


<% Option Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
On Error Resume Next    '*** Not Show ASP Error  ***'
Dim Conn1
Set Conn1 = Server.Createobject("ADODB.Connection")
Conn1.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/mydatabase.mdb"),"" , ""
If Err.Number <> 0 Then
Response.write("(Microsoft Access Driver) Database cannot connect Error = "&Err.Description&"<br>")
Else
Response.write("(Microsoft Access Driver) Database connected.<br>")
End If
Conn1.Close()
Set Conn1 = Nothing

Dim Conn2
Set Conn2 = Server.Createobject("ADODB.Connection")
Conn2.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("db/mydatabase.mdb"),"" , ""
If Err.Number <> 0 Then
Response.write("(OLE DB) Database cannot connect Error = "&Err.Description&"<br>")
Else
Response.write("(OLE DB) Database connected.<br>")
End If
Conn2.Close()
Set Conn1 = Nothing

Dim Conn3
Set Conn3 = Server.Createobject("ADODB.Connection")
Conn3.open "mydatabase","",""
If Err.Number <> 0 Then
Response.write("(ODBC) Database cannot connect Error = "&Err.Description&"<br>")
Else
Response.write("(ODBC) Database connected.<br>")
End If
Conn3.Close()
Set Conn3 = Nothing
%>
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_access_connect.asp

Screenshot

ASP & Microsoft Access
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.