Wednesday, March 21, 2012

ODBC connection failing

First of all i apologise if this is in the wrong area. My problem is as follows. I had set up a couple of aspx pages on our webserver which accessed a sql database on another server. These pages were set up using frontpage 2003 and everything worked fine. A week ago the pages stopped working giving the error "Server Error in '/' Application". As far as I know nothing has been changed on the servers. On top of this frontpage has started having connection problems. Frontpage will connect to the database but is unable to access the fields giving the following error.

Server error: Unable to retrieve schema information from the record source ' NAME' in a database using the connection string:

'DRIVER={SQL Server};SERVER=servername;DATABASE=live;UID=********;PWD=********'.

The following error message comes from the database driver software; it may appear in a different language depending on how the driver is configured.
-----------------
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'NAME'.

Source: Microsoft OLE DB Provider for ODBC Drivers
Number: -2147467259 (0x80004005)

I have been trying for the past few days to solve this one, but am reasonable new to SQL, so this may be an easy one.

Hope someone can help me

If all your pages are in aspx you might want to use the native support for SQL Server and use a SQL Connection string. Also, you might want to move your code to .NET.|||I appreciate the info, but i still need to solve my current problem.|||can you post your connectionstring and some code.|||

Here is the full global.asa page generated by Frontpage. I know the connection string is correct as all my other office apps can connect and work on any of the tables in this database without a problem, frontpage is the only one that will not access the tables, although it can see the tables. On top of this the webserver will aslo not access the tables either. For whatever reason Frontpage will no longer access the tables, when it used to quite happily. We do have another SQL DB on another server which it will connect to no problem, so I am wondering if it is a security issue, but I have been unable to find any settings between the two servers which are different.

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(1)
'--Project Data Connection
Application("sage_ConnectionString") = "DRIVER={SQL Server};SERVER=SERVERNAME;DATABASE=DBNAME;UID=LOGIN;PWD=PASSWORD"
Application("sage_ConnectionTimeout") = 15
Application("sage_CommandTimeout") = 30
Application("sage_CursorLocation") = 3
Application("sage_RuntimeUserName") = "LOGIN"
Application("sage_RuntimePassword") = "PASSWORD"
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==
End Sub
Sub Session_OnStart
FrontPage_StartSession '==FrontPage Generated==
FrontPage_ConvertFromODBC '==FrontPage Generated==
End Sub
Sub FrontPage_StartSession
On Error Resume Next
if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub

sFile = "global.asa"
sRootPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
if Left(sRootPath,1) = "/" then sSep = "/" else sSep = "\"
if Right(sRootPath,1) <> sSep then sRootPath = sRootPath & sSep
sRootPath = sRootPath & sFile

' discover the VRoot for the current page;
' walk back up VPath until we match VRoot
Vroot = Request.ServerVariables("PATH_INFO")
iCount = 0
do while Len(Vroot) > 1
idx = InStrRev(Vroot, "/")
if idx > 0 then
Vroot = Left(Vroot,idx)
else
' error; assume root web
Vroot = "/"
end if
if Server.MapPath(Vroot & sFile) = sRootPath then exit do
if Right(Vroot,1) = "/" then Vroot = Left(Vroot,Len(Vroot)-1)
iCount = iCount + 1
if iCount > 100 then
' error; assume root web
Vroot = "/"
exit do
end if
loop
' map all URL= attributes in _ConnectionString variables
Application.Lock
if Len(Application("FrontPage_VRoot")) = 0 then
Application("FrontPage_VRoot") = Vroot
UrlVarArray = Application("FrontPage_UrlVars")
for i = 0 to UBound(UrlVarArray)
if Len(UrlVarArray(i)) > 0 then FrontPage_MapUrl(UrlVarArray(i))
next
end if
Application.Unlock
End Sub
Sub FrontPage_MapUrl(AppVarName)
' convert URL attribute in conn string to absolute file location
strVal = Application(AppVarName)
strKey = "URL="
idxStart = InStr(strVal, strKey)
If idxStart = 0 Then Exit Sub
strBefore = Left(strVal, idxStart - 1)
idxStart = idxStart + Len(strKey)
idxEnd = InStr(idxStart, strVal, ";")
If idxEnd = 0 Then
strAfter = ""
strURL = Mid(strVal, idxStart)
Else
strAfter = ";" & Mid(strVal, idxEnd + 1)
strURL = Mid(strVal, idxStart, idxEnd - idxStart)
End If
strOut = strBefore & Server.MapPath(Application("FrontPage_VRoot") & strURL) & strAfter
Application(AppVarName) = strOut
End Sub
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
For each item in Application.Contents
if UCase(Right(item,slen)) = UCase(str) then
sName = Left(item,Len(item)-slen)
sConn = Application(item)
if InStr(LCase(sConn),"provider=") < 1 and Len(Application(sName & "_ConnectionTimeout"))>0 then
sArr = Split(sConn,";")
set oDict = Server.CreateObject("Scripting.Dictionary")
bUnknown = False
for i = 0 to UBound(sArr)
s = sArr(i)
idx = InStr(s,"=")
sKey = UCase(Trim(Left(s,idx-1)))
sVal = Trim(Mid(s,idx+1))
oDict.Add sKey, sVal
if Not oKnown.Exists(sKey) then bUnknown = True
next
if bUnknown = False and oDict.Exists("DRIVER") then
sDrv = oDict.Item("DRIVER")
sNew = ""
if InStr(sDrv,"Microsoft Access") > 0 and oDict.Exists("DBQ") and not (oDict.Exists("UID") or oDict.Exists("PWD")) then
sNew = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & oDict.Item("DBQ")
elseif InStr(sDrv,"SQL Server") > 0 and oDict.Exists("SERVER") and oDict.Exists("DATABASE") then
sNew = "Provider=SQLOLEDB;Data Source=" & oDict("SERVER") & ";Initial Catalog=" & oDict("DATABASE")
if oDict.Exists("UID") then sNew = sNew & ";User ID=" & oDict("UID")
if oDict.Exists("PWD") then sNew = sNew & ";Password=" & oDict("PWD")
end if
if sNew <> "" then
Application(item) = sNew
end if
end if
set oDict = Nothing
end if
end if
Next
Application.Unlock
Set oKnown = Nothing
End Sub
</SCRIPT>
<head><title>Web Site Settings for Active Server Pages</title><html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:connectionstatus msdt:dt="string">sage=1</mso:connectionstatus>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>

|||Sorry I got side tracked. I have no idea what to suggest. Are you creating an Access DB from your code? I see some Jet OLEDB and SQL OLEDB related connection strings.|||No, no Access DB is being created. This script is just setting the environment for the site itself. I can paste in the coding for the page itself if you require, but all the connection information is in the above script anyway. But the strange thing is, like i mentioned before, if i open frontpage now and create a new site (or open a present one) frontpage will not open any table on this DB. It can connect OK but gives me the error "object does not exist" when i try and open the table itself. this is the same for any table and any DB on this server. I assumed it was a security setting but can not find anything that is set to block this user account from accessing the tables.

No comments:

Post a Comment