Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



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
 
 
Register now for full access!
Old 02-07-2009, 06:45 AM Re: Cannot locate database
itHighway's Avatar
Skilled Talker

Posts: 83
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.
__________________
Zeeshan Dar
itHighway -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
itHighway is offline
Reply With Quote
View Public Profile
 
Old 02-07-2009, 07:01 AM Re: Cannot locate database
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Have you created a DSN called "20527796"?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
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.37832 seconds with 12 queries