Click to See Complete Forum and Search --> : Can't open a connection to a database


davidng
11-11-2007, 06:32 PM
Hi. I'm trying to open a connection to a database (for example purposes, I'll call it database.dsn) using the following code:

<%
Dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "DSN = database.dsn"
conn.Open
%>

However, the set conn = Server.CreateObject("ADODB.Connection") line gives me an "Invalid class string" error when trying to open the page. Can anyone help? I'm using IIS 5.1 on XP Pro.

gil davis
11-12-2007, 07:51 AM
conn.ConnectionString = "DSN = database.dsn"
Have you tried it without the spaces?

You could also try this:
conn.ConnectionString = "DSN=database.dsn;Uid=;Pwd=;"

davidng
11-12-2007, 12:19 PM
Doing it without the spaces worked, thanks!