Can't connect to database -Data source name not found and no default driver specified

Discussion in 'Databases' started by alexf40, May 8, 2012.

  1. Hello to everyone, I'm a newbie to both Winhost and ASP :)

    I'm very grateful for any help in which can be given whilst I learn the ropes.

    I'm having trouble trying to connect to a MS SQL database I've setup, I keep getting the following error:

    Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'
    
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    
    /DatabaseCon.lib, line 18 

    As far as I know I've set up the DSN correctly "DSN_souther3_org4me s07.Winhost.com"

    And this is how I'm connecting to the database:

    Code:
    <%
    Dim objConn
    dim strDB
    'strDB = Server.MapPath("..\cgi-bin\org4me.mdb")
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    'objConn.Mode = 3
    'objConn.Connectionstring = "DSN=DSN_souther3_org4me"
    'objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strDB
    'objConn.ConnectionString = "DRIVER={SQL Server}; UID=###_org4me_user; PWD=###; DATABASE=DB_###_org4me; SERVER=(local)"
    'objConn.ConnectionString = "Data Source=tcp:s07.Winhost.com;Initial Catalog=DB_###_org4me;User ID=DB_###_org4me_user;Password=###;Integrated Security=False;"
    
    If objConn.State <> 0 Then
    	Response.write objconn.state
    	Response.write "Database is temporarily busy"
    	Response.write "<BR>Please wait a few seconds and then <a href=""javascript:location.reload()"" target=""_self"">REFRESH</a> or try again later."	
    End IF
    objConn.Open
    
    
    'Dim sConnection
    'Set objConn = Server.CreateObject("ADODB.Connection")
    'sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    '              "Data Source=" & Server.MapPath(".\database\org4me.mdb") & ";" & _
    '              "Persist Security Info=False;PWD=wwsucks"
    'objConn.Open(sConnection)
    
    %>
    Any help in what I'm doing wrong would be fantastic.

    Many thanks
    Alex
     
    Last edited by a moderator: Oct 14, 2015
  2. Elshadriel

    Elshadriel Winhost Staff

    Last edited by a moderator: Oct 14, 2015
  3. Hi thanks for the response.

    I've now got a connection from using this FAQ:
    How to query a SQL Server with DSN/ODBC name source

    But now I'm getting the following error, even though it was working fine on the previous server:

    Microsoft VBScript runtime error '800a01f4'

    Variable is undefined: 'objConn'

    /org4me/DiveLocker.lib, line 16


    Should I have kept any of the following code from the old DatabaseCon.lib?

    I've just used the exact code from the FAQ.

    Code:
    <%
    Dim objConn
    dim strDB
    'strDB = Server.MapPath("..\cgi-bin\org4me.mdb")
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    'objConn.Mode = 3
    'objConn.Connectionstring = "DSN=DSN_souther3_org4me"
    'objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strDB
    'objConn.ConnectionString = "DRIVER={SQL Server}; UID=###_org4me_user; PWD=###; DATABASE=DB_###_org4me; SERVER=(local)"
    'objConn.ConnectionString = "Data Source=tcp:s07.Winhost.com;Initial Catalog=DB_###_org4me;User ID=DB_###_org4me_user;Password=###;Integrated Security=False;"
    
    If objConn.State <> 0 Then
    	Response.write objconn.state
    	Response.write "Database is temporarily busy"
    	Response.write "<BR>Please wait a few seconds and then <a href=""javascript:location.reload()"" target=""_self"">REFRESH</a> or try again later."	
    End IF
    objConn.Open
    
    
    'Dim sConnection
    'Set objConn = Server.CreateObject("ADODB.Connection")
    'sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    '              "Data Source=" & Server.MapPath(".\database\org4me.mdb") & ";" & _
    '              "Persist Security Info=False;PWD=wwsucks"
    'objConn.Open(sConnection)
    
    %>

    Thanks
     
    Last edited by a moderator: Oct 14, 2015
  4. Elshadriel

    Elshadriel Winhost Staff

    It looks like you have a lot of the code commented out?
     
  5. This is the code I'm using now, as from the FAQ.

    Code:
    <% 
    Dim cnnSimple  ' ADO connection 
    Dim rstSimple  ' ADO recordset 
    Set cnnSimple = Server.CreateObject("ADODB.Connection") 
     
    ' DSNLess 
    cnnSimple.Open ("DSN=DSN_souther3_org4me; User Id=DB_*****_org4me_user;Password=******;") 
     
    Set rstSimple = cnnSimple.Execute("select * from sysfiles") 
    %> 
    <P> Connecting to Access with Ole connection </P> 
     
    <table border="1"> 
    <% 
    Do While Not rstSimple.EOF 
     %> 
     <tr> 
      <td><%= rstSimple.Fields(0).Value %></td> 
      <td><%= rstSimple.Fields(1).Value %></td> 
     </tr> 
     <% 
     rstSimple.MoveNext 
    Loop 
    %> 
    </table> 
    <% 
     
    rstSimple.Close 
    Set rstSimple = Nothing 
    cnnSimple.Close 
    Set cnnSimple = Nothing 
    %> 

    This is what is giving the error.

    Microsoft VBScript runtime error '800a01f4'

    Variable is undefined: 'objConn'

    /org4me/DiveLocker.lib, line 16




    Thanks again
     
  6. Elshadriel

    Elshadriel Winhost Staff

    I don't see a reference to any variable named 'objConn' in the code you provided.
     
  7. Sorry this is line16 from the file it's referencing.

    Code:
    objRS_DL.Open "SELECT * FROM Members INNER JOIN DiveLocker ON Members.ID=DiveLocker.Member_ID WHERE (((DiveLocker.Last_Notification)<=DateAdd(m,-[Interval]," & date() & "))) AND Notification=1 ORDER BY Members.email;", objConn
    Thank you for your help. This is my first dab at ASP and I'm really struggling and now realise how simple php/mysql is.
     
  8. Elshadriel

    Elshadriel Winhost Staff

    I would need to see more code in order to understand what may be happening.
     

Share This Page