Quick ASP question

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
Perseid
Padawan Learner
Posts: 357
Joined: 2005-03-10 09:10am
Location: Somewhere between Here and There

Quick ASP question

Post 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
Image
User avatar
His Divine Shadow
Commence Primary Ignition
Posts: 12791
Joined: 2002-07-03 07:22am
Location: Finland, west coast

Post 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;"
Those who beat their swords into plowshares will plow for those who did not.
User avatar
Perseid
Padawan Learner
Posts: 357
Joined: 2005-03-10 09:10am
Location: Somewhere between Here and There

Post 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?
Image
User avatar
His Divine Shadow
Commence Primary Ignition
Posts: 12791
Joined: 2002-07-03 07:22am
Location: Finland, west coast

Post 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.
Those who beat their swords into plowshares will plow for those who did not.
User avatar
Perseid
Padawan Learner
Posts: 357
Joined: 2005-03-10 09:10am
Location: Somewhere between Here and There

Post 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
Image
User avatar
Perseid
Padawan Learner
Posts: 357
Joined: 2005-03-10 09:10am
Location: Somewhere between Here and There

Post 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
Image
User avatar
His Divine Shadow
Commence Primary Ignition
Posts: 12791
Joined: 2002-07-03 07:22am
Location: Finland, west coast

Post 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;"
Those who beat their swords into plowshares will plow for those who did not.
Post Reply