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
Hi Alex, You might want to compare your code with the sample code we provide in our Knowledge Base: http://support.Winhost.com/KB/a688/how-to-query-sql-database-with-asp-using-dsn-less-connection.aspx http://support.Winhost.com/KB/a759/how-to-query-a-sql-server-with-dsnodbc-name-source.aspx
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
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
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.