User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 392,088 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,938 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 9076 | Replies: 2
Reply
Join Date: May 2007
Posts: 1
Reputation: syarafina is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
syarafina syarafina is offline Offline
Newbie Poster

how to connect ms access with asp vbscript

  #1  
May 8th, 2007
im a student of softare engineering corses..i hav a problem.how to insert document that we fill in the table ms access.. tq.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: india
Posts: 143
Reputation: katarey is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 15
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Tutorial Re: how to connect ms access with asp vbscript

  #2  
May 9th, 2007
Hi there,

Well I am not a good tutorial writer but I am trying to explain how to make the connection with database (Ms Access) using asp,

Assumptions:
Running IIS 6
First here the directory plans:

Folders:
Websiteroot
Includes
Database

Websiteroot: - this folder will contain the full website
Includes: - this folder will contain the file where we will write the connection script
Database: - *here our database will be,

Files:
Websiteroot/default.asp
Websiteroot/includes/connectionFile.asp
Websiteroot/Database/dbFile.mdb

default.asp: Home Page of our website (here we’ll only show some records from database).
connectionFile.asp: here we’ll put connection script.
dbFile.mdb: Database File (Ms Access)

connectionFile.asp:
<%
'Declare Variables
Dim ConnString, conn, DatabaseLocation

'Assigning the database location into a variable,
'Using ASP MapPath Method, The MapPath method maps a specified path to a physical path.
DatabaseLocation = Server.MapPath("/Database/dbFile.mdb")

'Creating Sub, Where we'll need to open the DataBase we'll use this sub
'Creating this Sub is Not Necessary, You can use directly code this inside of this Function/Sub
Sub OpenDataBase()
'ADO Connection Object
'The ADO Connection Object is used to create an open connection to a data source.
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open DatabaseLocation
End Sub
'Creating Sub, To Close Database
'Creating this Sub is Not Necessary, You can use directly code this inside of this Function/Sub
Sub CloseDataBase()
conn.close
End Sub
%>


default.asp:[HTML]
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Websiteroot/includes/connectionFile.asp " -->
<%
'Open Database
OpenDataBase()
'Create Recordset
'ADO Recordset Object
'The ADO Recordset object is used to hold a set of records from a database table.
'A Recordset object consist of records and columns (fields).
set rs = Server.CreateObject("ADODB.Recordset")
sql = "Select * from users"
rs.Open sql, conn
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DataBase Connection Tutorial</title>
</head>
<body>
<!-- Form Not Submited Yet-->
<table width="50%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>User Id</td>
<td>User Name</td>
</tr>
<%
c=0
do while not rs.eof
c=c+1
%>
<tr>
<td><%=rs("uid")%></td>
<td><%=rs("username")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
Set rs = nothing
CloseDataBase()
%>
</body>
</html>[/HTML]

I hope this will Helpful For you,

this thread also useful for you

http://www.daniweb.com/techtalkforums/thread69174.html

Best regards,
Rahul Dev

I have Attached all Files used,
Attached Files
File Type: zip websiteroot.zip (12.5 KB, 61 views)
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote  
Join Date: May 2007
Posts: 5
Reputation: manleys_web is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
manleys_web manleys_web is offline Offline
Newbie Poster

Re: how to connect ms access with asp vbscript

  #3  
May 9th, 2007
try the asp and ado pages on www.w3schools.com too
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 12:37 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC