[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1237
  • Last Modified:

Connecting to an Access Database Using File DSN and ASP/ADO

My question is concerning how to use ASP in conjuction with a hosting service through godaddy.com.

I am unfamiliar on what godaddy.com's help center is suggesting I change my scripting so that it will work.  I have ran my current ASP pages, built in dreamweaver, locally which have worked.  However when I uploaded them, using godaddy.com's FTP, it yeild a line 4 error <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>.

I want to include my scripting in the question but I am not sure where to start or what part to include aside from copying everything and pasting it which could just do more harm than good.  

I would really appreciate help with this question because right now it is over my head.  I assigned this question 250 points assuming that is means its out of my leauge.  

Here are some specific resources concerning my problem:
*godaddy's.com's help center code template which I am supposed to incorporate into my code*

<%
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

%>
0
Papaschack
Asked:
Papaschack
1 Solution
 
Ryan ChongCommented:
What happen if remove the line:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>.

from your script ?
0
 
RouchieCommented:
Firstly, this line
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
should be the first line on the page and should come before anything else.

Secondly, it may be that ASP has not actually been activated on your hosting account.  Create a new ASP file with the following content and upload it to the godaddy server.  When run in the browser you should see the time and date shown.

<html>
<body>
<%=now()%>
</body>
</html>

Lastly, ensure that the DSN has been created on the godaddy server and that you are referencing it correctly.  It is unlikely that your page will work on their server as-is because the DSN settings are different for each machine usually.  You need to create the DSN on the new server, or access the database from ASP using a direct connection string.
0
 
Ryan ChongCommented:
if you added:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

on the first line on the page, i'm afraid the native language for your ASP scripting will becomes as Javascript, but not by default the Vbscript.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
Onyx23Commented:
You need this:   <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> or at the very least   <%@LANGUAGE="VBSCRIPT" %>      at
the beginning of your page because you have VBscript Base code (ASP)


This -------------> <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>    Should not be the first line of your code.

 Start with this issue first using process of elimination. Then report additional problems if you have any.
0
 
PapaschackAuthor Commented:
*here is the code that I am using.  The problem is still present but I have attempted to incorporate godaddy.com's code that I included above.  

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
Dim oConn, oRs
Dim qry, connectstr, sDSNDir
Dim db_name, db_username, db_userpassword
Dim db_server, dsn_name

dsn_name = "dsn_connection.dsn"
fieldname = "your_fieldname"
tablename = "your_tablename"

sDSNDir = Server.MapPath("dsn_connection.dsn")

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

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM car_detail"
Set oRS = oConn.Execute(qry)
%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>

<%=now()%>


<%
if not oRS.EOF then
while not oRS.EOF
response.write "Year: " & oRs.Fields(car_year) & " <br>"

oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

%>
</body>
</html>
0
 
Ryan ChongCommented:
try:

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

dsn_name = "dsn_connection.dsn"
fieldname = "your_fieldname"
tablename = "your_tablename"

sDSNDir = Server.MapPath("dsn_connection.dsn")

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

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM car_detail"
Set oRS = oConn.Execute(qry)
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>

<%=now()%>


<%
if not oRS.EOF then
while not oRS.EOF
response.write "Year: " & oRs.Fields(car_year) & " <br>"

oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

%>
</body>
</html>
0
 
PapaschackAuthor Commented:
I want to double check what are the necessary things that I need to have for this script to work.  

1. I need the correct dsn, which is set up through odbc in the administrative controls from the control panel.  
-My question is do I use the file dsn tab once within the odbc option menu?

Because within the above script I use a file dsn.

2.  After I have the correct file dsn in place I upload the page, using the ftp, onto the hosting site.  Once I do this will I be able to view the page, or be able to verify that it works?

0
 
Ryan ChongCommented:
>>My question is do I use the file dsn tab once within the odbc option menu?
I'm not sure what you are asking here... basically you can upload this asp file to your server and try to run it, to see whether it's ok or not.

regards
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now