Reply
Cannot locate database
Old 02-05-2009, 07:00 PM Cannot locate database
Junior Talker

Posts: 4
Name: Rcardo
Trades: 0
Hi there,

Upon following an example from an ASP book, i have stumbled across the MS Access data source connection error message:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/20527796/assignment2/verify.asp, line 115


I have been told to specify the database name as my user ID (20527796) which i have also specified in the code:

(global.asa)
Code:
Code:
<SCRIPT LANGUAGE=vbscript RUNAT=Server>

    Sub Application_OnStart()
        Application("SiteURL") = "http://intasp.bcuc.ac.uk/20527796/assignment2/"
        Application("DBSource") = "20527796"
        Application("LogonErrFile") = "LogonErr.asp"
        Application("AccessErrFile") = "AccessErr.asp"    
    End Sub
    
    Sub Session_OnStart()
        Session("IsGoodUser") = False
        Session("FirstName") = ""
        Session("LastName") = ""
        Session("CurrentURL") = ""
        Session("UserID") = ""
    End Sub
    
    Sub Application_OnEnd()

    End Sub
    Sub Session_OnEnd()
        Session.Abandon
    End Sub
</SCRIPT>
default.asp contains the log in dialog. verify.asp is fired up once the visitor clicks 'logon' to verify that they are registered within the database and that the user name and password matches. verify.asp checks the database for these items, but its seems as though it cannot locate the database:

(verify.asp)
Code:
Code:
<%

Sub GetNames(LoginID, FirstName, LastName)

    Dim cn 'Connection var
    Dim rs 'Recordset var
    Dim strSQL 'SQL Statement var
    Dim strCn 'Connection String var
    

    'Create a Connection Object
    Set cn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    'Make the SQL statement that returns
    'the user with password, should one exist
    strSQL = "SELECT * FROM tblTeachers WHERE TeacherID = '"
    strSQL = strSQL & LoginID & "'"
    

    'Set error trappong
   'On Error Resume Next
    'Open the Connection
    cn.ConnectionString = "DSN=" & Application("DBSource")
    cn.Open
    If Err Then Exit Sub

    'Get the user from the DB
    rs.Open strSQL, cn
    If Err Then Exit Sub

    'This checks to make sure if no
    'recordset was returned
    MyErr = rs("FirstName")
    If err then
        Exit Sub
    End if
    'Wire up the return fields
    FirstName = rs("FirstName")
    LastName = rs("LastName")

    rs.Close
    cn.Close
End Sub


Function Login(LoginID, Password)


    Dim cn 'Connection var
    Dim rs 'Recordset var
    Dim strSQL 'SQL Statement var
    Dim strCn 'Connection String var
    
   

    'Create a Connection Object
    Set cn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    'Make the SQL statement that returns
    'the user with password, should one exist
    strSQL = "SELECT * FROM tblLogin WHERE LoginName = '"
    strSQL = strSQL & LoginID & "'"
    

    'Set error trappong
   On Error Resume Next
    'Open the Connection
    cn.ConnectionString = "DSN=" & Application("DBSource")
    cn.Open
    If Err Then Exit Function

    'Get the user from the DB
    rs.Open strSQL, cn
    If Err Then Exit Function

    'This checks to make sure if no
    'recordset was returned
    MyErr = rs("PWD")
    If err then
        Exit Function
    End if

    'If the passwords match up, return TRUE
    If rs("PWD") = Password Then
        Login = True
    Else
       Login = False
    End If
    'Leave town
    rs.Close
    cn.Close
End Function

'=========Entry Point============
If Login(Request.Form("LoginID"), Request.Form("PWD")) Then
    'Set a session level var for the UserID
    Session("UserID") = Request.Form("LoginID")

    Dim FirstName
    Dim LastName


    'Get the teachers First Name and Last Name
    GetNames Session("UserID"), FirstName, LastName

    'Set a session level var for the FirstName and LastName
    If FirstName <> "" Then Session("FirstName") = FirstName
    If LastName <> "" Then Session("LastName") = LastName
    'If the login data is good, redirect the visitor
    'to the site's content directory
    Session("IsGoodUser") = True
    Response.Redirect "main.asp"
Else
    'Report a logon error.
    Response.Redirect Application("LogonErrFile")
End If
%>
It may be that the connection string is of the wrong type for the desired connection. If this is the problem, is there an alternative way to connect to the database.

p.s. I have granted full access permissions over the database to eliminate permission problems.

Any help towards this quandrary will be appreciated.

Many thanks,

stroodle!

Last edited by stroodle; 02-05-2009 at 07:04 PM..
stroodle is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 02-07-2009, 06:45 AM Re: Cannot locate database
itHighway's Avatar
Skilled Talker

Posts: 73
Name: Zeeshan Dar
Location: GUJ
Trades: 0
I checked the code and it all seems to be fine. Try changing the DSN name from numerica to alphanumeric.
itHighway is offline
Reply With Quote
View Public Profile
 
Old 02-07-2009, 07:01 AM Re: Cannot locate database
chrishirst's Avatar
Super Moderator

Posts: 22,226
Location: Blackpool. UK
Trades: 0
Have you created a DSN called "20527796"?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Cannot locate database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11372 seconds with 13 queries