Page 1 of 1

Quick ASP question

Posted: 2006-10-10 04:53am
by Perseid
I'm writing a web form with an ms access database in the backend, however I cannot get the ASP form to connect to the access database. I've looked around the web and in the books that I've got but all of the code that they've used is the same as what i've already got.
Any ideas, thanks in advance for any help

Posted: 2006-10-10 05:42am
by His Divine Shadow
Here's how I usually connect:

Code: Select all

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\path\database.mdb;"

Posted: 2006-10-10 07:45am
by Perseid
My version of the connect code goes like this:

Code: Select all

Dim Conn As OleDbConnection
Conn = New OleDbConnection("PROVIDER = Microsoft.Jet.OLEDB.4.0;DATA Soure=c:\path\database.mdb")
however whenever i run the web form i keep getting the following
ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
any ideas?

Posted: 2006-10-10 07:52am
by His Divine Shadow
Yes, I think it's because you lack this line:
Set Conn = Server.CreateObject("ADODB.Connection")

Doesn't seem to me you are actually creating a connection anywhere, just the linking part. Try and replace the path in my code and replace it and see if it works or not.

Posted: 2006-10-10 08:44am
by Perseid
For some reason I can't put the set command in (something to do with asp 2.0 not using set) so the adodb string looks like this:

Code: Select all

Conn=Server.CreateObject("ADODB.Connection")
also Conn.Open won't take in the provider details

Posted: 2006-10-10 08:47am
by Perseid
this is my current open connection string

Code: Select all

        command = New OleDbCommand(SQLstatement, Conn)
        Try
            Conn.Open()
        Catch
            command.ExecuteNonQuery()
        Finally
            Conn.Close()
        End Try

Posted: 2006-10-10 09:03am
by His Divine Shadow
ASP 2.0 eh? Never used that, but I am still stuck on ASP 3.0 anyway.

Just guessing but maybe ASP 2.0 is more a bitch when it comes to set command, maybe you can use the set command if you use dim?

Code: Select all

Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\somepath\dbname.mdb;"