Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem connecting Access Databases to Website 1

Status
Not open for further replies.

SOG61

Technical User
Sep 18, 2005
47
GB
About six months ago I had to change my Server for my Old Boys Association Website to the 1&1
Ever since then when I try to open any page containing an Access Database I get the following error


Database Results Error
The database connection named 'oldboys2.mdb' is undefined.

This problem can occur if:
* the connection has been removed from the web
* the file 'global.asa' is missing or contains errors
* the root folder does not have Scripting permissions enabled
* the web is not marked as an Application Root

I have been in touch with 1&1 on countless occasions but have not been able to solve the problem
The site worked perfectly OK with our previous server
I have tried building a new page through a different Website but still get the same response
When I view the main page with a fault through Fron Page I get the following error report

This is the start of a Database Results region. The page must be fetched from a web server with a web browser to display correctly; the current web is stored on your local disk or network.

Unfortunately my knowledge on this subject is very limited, ie I have tried to learn it by reading various books, which I find difficult to understand

from an ignorant SOG61
 
Try a dsn-less connection instead of depending on global.asa to attach to your website.
 
XWB

Thanks for the response, I found out what instruction to add but in my ignorance I was not sure where it should be added so I added it to one of the pages that was not working, no change, I then moved the instruction to global.asa without any luck, I then tried it in both places still no change. Hope I have done this correctly.
Unfortunatley my knowledge on this is very limited
Regards SOG61
 
global.asa is a bit of a pain. The system only looks at global.asa which is at root level: not the one on your website. As a result, nothing will work whatever you do to global.asa.

Try this first. Replace

zzz with the name of your database
YYY with the key field
XXX with the table
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<title>DB Test</title>
</head>
<body>
<%
dim conn, mdbpath, connstr, sqlQuery
mdbpath = Server.MapPath("zzz.mdb")
sqlQuery = "select * from XXX"
'
' This is the same for all the DBs
set conn = Server.CreateObject("ADODB.Connection")
connstr = "Driver={Microsoft Access Driver (*.mdb)};"
connstr = connstr & "DBQ=" & mdbpath & ";"
conn.Open connstr
set rs = conn.Execute (sqlQuery)
%>
<ul>
<%
while not rs.eof
%>
<li><%=rs("YYY")%>
<%
    rs.MoveNext
wend
conn.Close
%>
</body>
</html>
Save it as Test.asp (note the uppercase T). Download it and run it as test.asp

If this doesn't work, i.e. it says "page not found" you have a Unix server which does not support access. You probably have to try another server. Unix is case sensitive, windows is not. In Unix, Test.asp and test.asp are two different files. On Windows, they are the same file.

If it works, this will list all the records in the database. If it doesn't, then check

- has the database been downloaded?
- is the relative path for the database correct?

Assuming it works, would it be possible to check whether your global.asa has been uploaded. It is just a long shot. Your global.asa may be the top level one but if it does not exist, then your web page won't be able to find it.

That is all I can think of right now.
 
Dear xwb
Many thanks for the advice, I have loaded the file as mentioned and I get the message - 'Page not found' as you also mentioned
I have had a look at my Web Server details, I am with 1&1 and have Business Pro Package, which says it supports Access + 2 x MSSQL Databases and that the Server is Linux.
I upgraded to the Business Pro package as an attempt to cure this problem, but to date all it has done is cost me more money and almost drive me round the bend.
I will continue fiddling in the hope of getting somewhere.
The problem with 1&1 is that get a response from a Technician, and when you reply you get the response from someone else and they go off on different paths, but never seem to answer the actual question
Regards SOG61
 
I'm not sure if Linux supports access but just in case it does, you are probably using some form of Unix ODBC. Anyway there can be several things that don't work. Try this: put it in a file called now.asp and upload it to your server and run it. If it works, it will tell you the time, if it doesn't then you have to ask your provider to enable asp.
Code:
<html>
<head><title>ASP Check</title></head>
<body>
<p>ASP working - <b>
<%= Time %>
</b></p>
</body></html>
If that works, the next step is to find out whether it supports vbscript. Frontpage generates the client side in Javascript but the server side is always vbscript. There may be a way of changing it but I don't know what it is. Put this in vbstest.asp
Code:
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head><title>VBScript Test</title>
<body><p>
<%
for i=0 to 10
   Response.Write "Working " & cstr(i)& "<br/>"
next
%>
</p></body>
</html>
You should get 10 items saying working. If that doesn't work try the same thing in javascript, otherwise skip this bit.
Code:
<%@LANGUAGE="JAVASCRIPT"%>
<html>
<head><title>JavaScript Test</title>
<body><p>
<%
for (i = 0; i < 10; ++i)
   Response.Write ("Working " + cstr(i) + "<br/>")
%>
</p></body>
</html>
If JavaScript works, then you have to ask 1&1 to put you on to a server that supports vbscript or find a way in frontpage of regenerating everything in javascript.

If you are past the vbscript bit, try a simple query. Run up Test.asp in my first posting. Do you get any results back from it? If you don't, check the mdb filename. Unix is case sensitive so make sure that if you have typed everything in lowercase on your pc, that it is still in lowercase in test.asp. If that still doesn't work, try changing the database filename to uppercase in the asp file.

If all that works, then your server may not be front page enabled. Just ask 1&1 if it is frontpage enabled. If it isn't and they can't do it, then you will have to rewrite the queries as dsn-less connections. It isn't as daunting as it sounds. See how you get on - if it needs rewriting, I can give you a template.
 
xwb
Sorry to have to come back to you again, queried the asp activation with 1&1, but made the faullt of asking them about the error report, so they checked the link and told me that they get a different error, needless to say no suggestion of how to amend, also ignored the asp question.
Referring back to your previous piece about Test.asp, I am wondering if I entered the correct details, I note you said Key field to be put in YYY, not sure what I should have put in there (sorry my ignorance again). The response from 1&1 re error report was different to mine, they got:

Microsoft VBScript compilation error '800a0400'
Expected statement
/LM/W3SVC/40315680/ROOT/global.asa, line 28
<%
^

While I get the following on my Computer at home:

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
Please try the following:
Open the home page, and then look for links to the information you want.

Click the Refresh button, or try again later.
Click Search to look for information on the Internet.
You can also see a list of related sites.
HTTP 500 - Internal server error
Internet Explorer

My Computer at work brings up the same error as 1&1 get.

Seems weird to me as I cannot rely on the error reports at home, incidentally they were the same on all computers before we started trying to solve it.

SOG61
 
When I click on "old boys", I get
Code:
<% Set demoConn = Server.CreateObject("ADODB.Connection") demoFilePath = "C:\NewWebsites\odwa2006\fpdb\oldboys2.mdb" demoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & demoFilePath & ";" %>

TIME: <% =Time() %>

DATA: <% =Application("oldboys2.mdb_ConnectionString") %>
which suggests that it is not recognized.

1) Make sure the file has the extension .asp. The system will not pick up asp files if they end with htm.
2) Your demofilepath should be relative to your website location. Do not use absolute filenames.

I don't get the error that you get.
 
xwb

Thanks again for your assistance, one of the links that I have been having the main problem with is:


The main page of the site opens, but when I click on the 1955-59 section (oldboysdb1955-59.asp) I get the message page can not be displayed, this used to produce the 5 year age span from the database, and other links did similar for the other age groups.

Referring back to your previous piece about Test.asp, I am wondering if I entered the correct details, I note you said Key field to be put in YYY, not sure what I should have put in there (sorry my ignorance again).

Regards SOG61
 
YYY can be any field.

OK - I've tried your web page. Gets error 800A03EA. Basically moaning about illegal characters. This is most likely something to do with the table or database names.
A good ref for these errors is Check that

1) there are no spaces
2) there are no - (hyphens). If you have to use a hyphen, replace it with an underscore

Alternatively, could you post the first 24 lines of global.asa.
 
xwb

Many thanks once again for your perseverance with me, if only 1&1 would show similar interest, I still haven't got an answer to my message of yesterday morning about asp being enabled.

first 36 lines of global.asa follows:

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(2)
'--Project Data Connection
Application("Database1_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=htdocs/forms/oldboys2.mdb;UID=u40315680;PWD=fed2well"
FrontPage_UrlVars(0) = "Database1_ConnectionString"
Application("Database1_ConnectionTimeout") = 15
Application("Database1_CommandTimeout") = 30
Application("Database1_CursorLocation") = 3
Application("Database1_RuntimeUserName") = "u40315680"
Application("Database1_RuntimePassword") = "fed2well"
'--Project Data Connection
Application("Sample_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/FPNWIND.MDB"
FrontPage_UrlVars(1) = "Sample_ConnectionString"
Application("Sample_ConnectionTimeout") = 15
Application("Sample_CommandTimeout") = 30
Application("Sample_CursorLocation") = 3
Application("Sample_RuntimeUserName") = ""
Application("Sample_RuntimePassword") = ""
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==
Sub FrontPage_ConvertFromODBC
On Error Resume Next
if Len(Application("ASP_OS")) > 0 then exit sub
str = "_ConnectionString"
slen = Len(str)
set oKnown = Server.CreateObject("Scripting.Dictionary")
oKnown.Add "DRIVER",""
oKnown.Add "DBQ",""
oKnown.Add "SERVER",""
oKnown.Add "DATABASE",""
oKnown.Add "UID",""
oKnown.Add "PWD",""
Application.Lock

Incidentally I still get the Unable to display page error for the same link, is this because the actual fault ison this computer, seems weird to me. Thanks again

SOG61
 
You need to change your global.asa and upload it again. There is an end sub missing.
Code:
       Application("Sample_RuntimePassword") = ""
    '--
    Application("FrontPage_UrlVars") = FrontPage_UrlVars
    '==FrontPage Generated - endspan==
[B]end sub[/b]
Sub FrontPage_ConvertFromODBC
    On Error Resume Next
    if Len(Application("ASP_OS")) > 0 then exit sub
 
Just as a matter of interest, which version of frontpage are you using? In the global.asa that frontpage creates for me (both 2000 and XP), the next sub is Session_OnStart, followed by FrontPage_StartSession. I've never seen Fontpage_ConvertFromODBC.
 
Dear xwb

Thanks again, I thing we might be getting somewhere now, having changed the global.asa as you mention, and visiting the site I now get the message:

Database Results Wizard Error
The operation failed. If this continues, please contact your server administrator.

So I assume I need to try and get some sense out of 1&1

I am using Front Page 2003

Regards SOG61
 
I'm just wondering whether something happened to your global.asa. Is it the same size as when it did work?

Try something - create a new website using front page. Use the database wizard to generate something similar to oldboysdb1955-59.asp. Exit front page. Compare the global.asa generated with the one you posted to your website. The bits in Application_onStart will be different but is the stuff after the first end sub the same?

I don't have FrontPage2003 so I can't check whether the first routine after Application_onStart is Sub FrontPage_ConvertFrom ODBC.

If it isn't, create another global.asa with

a) All the code up to the first end sub from the old global.asa
b) All the code after the first end sub from the new global.asa

A bit like Terry Wogan in the BBC advert after he has removed his shirt. Then try uploading this global.asa and see what you get.
 
Dear xwb
On printing out a new global.asa and comparing it with the existing one, at a quick glance it look like a whole section has been duplicated in the one I am using, 3 and a bit pages against 2 and a bit on the new one.
I will back up both files and then try concocting the two.
I am also checking out an older Computer which still has Front Page 2000 running on it for some reason, although I was getting the problem then as well.
Regards SOG61
 
Dear xwb

I have deleted the global file and before changing it I found an old version dated May 2002, uploaded that, and EUREKA the pages work again after over six months

Thanks a million for your excellent help

Kindest regards SOG61
 
There is still the problem when clicking on oldboys. I think if you just change the extension from oldboys.htm to oldboys.asp, that should fix it.
 
xwb
Thanks for spotting that, I thought I had checked it all, even the picture database links on the home page work OK.

Tried changing title to oldboys.asp and it just stops the whole page loading and I get the Page cannot be displayed error back, but as soon as I try one of the other page Old Boys links that I did not change the page opens ok as oldboys.htm, so have changed it back.
Just printing out a page that does work OK to compare with the one that doesn't to see if anything funny has slipped in, although to the best of my knowledge these pages should not have changed.
Pity about this because I was so pleased, I keep going to the site to make sure it is still OK. Have already had a few congratulations, to pass on to you
Regards SOG61
 
xwb
I have compared the printout and can't see anything obvious, but of course it does differ as the Old Boys section is also part of a search option.
Re your other suggestion, when I use the link


I get the HTTP 500 error, the page cannot be displayed

where as


is needed to get main page up to go to the other searches

Regards SOG61
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top