View Single Post
Old 27-Feb-2007, 04:12 AM   #1 (permalink)
Sangeetha
Fixed Error!
 
Sangeetha's Avatar

Posts: 139
Location: Chennai
Join Date: Feb 2007
Rep Power: 2 Sangeetha is on a distinguished road

IM:
Default How I connect an Access Database

Question
Im using dreamweaver and my host is goddady
How I connect an Access Database Using File DSN and ASP/ADO?

Goddady help file said:
The purpose of the Windows file DSN (data source name) is to centrally store your database connection information. If you have many Web pages that require database access, this feature enables you to simply reference the path of the file DSN instead of having to provide the database connection details on every page.

For security reasons, the file DSN is kept in a sub-directory of your hosting content directory that cannot be viewed by anonymous Web users. The file DSN works with ASP and uses ADO to access a database. This directory is named "_dsn" and you can find it at the root of your hosting account.
What is a File DSN? - Help Center—Knowledge Base and FAQ

I have a database with two tables ( the name is listados.mdb and the tables are usuarios and propiedades)


The help center of goddady the following asp script but I need your help.

1.What i need to change in this script?
2.I need to put this script exactly in a asp page?
3. What more I need to do? Can you expline to me More Specific?

<%
Dim oConn, oRs
Dim qry, connectstr, sDSNDir
Dim db_name, db_username, db_userpassword
Dim db_server, dsn_name

dsn_name = "your_dsn_name"
fieldname = "your_fieldname"
tablename = "your_tablename"

sDSNDir = Server.MapPath("_dsn")

connectstr = "filedsn=" & sDSNDir & "\" & dsn_name

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & " "
oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

%>
Sangeetha is offline   Reply With Quote