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
Quick ASP question
Moderator: Thanas
- His Divine Shadow
- Commence Primary Ignition
- Posts: 12791
- Joined: 2002-07-03 07:22am
- Location: Finland, west coast
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.
- Perseid
- Padawan Learner
- Posts: 357
- Joined: 2005-03-10 09:10am
- Location: Somewhere between Here and There
My version of the connect code goes like this:
however whenever i run the web form i keep getting the following
Code: Select all
Dim Conn As OleDbConnection
Conn = New OleDbConnection("PROVIDER = Microsoft.Jet.OLEDB.4.0;DATA Soure=c:\path\database.mdb")
any ideas?ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
- His Divine Shadow
- Commence Primary Ignition
- Posts: 12791
- Joined: 2002-07-03 07:22am
- Location: Finland, west coast
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.
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.
- Perseid
- Padawan Learner
- Posts: 357
- Joined: 2005-03-10 09:10am
- Location: Somewhere between Here and There
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:
also Conn.Open won't take in the provider details
Code: Select all
Conn=Server.CreateObject("ADODB.Connection")
- Perseid
- Padawan Learner
- Posts: 357
- Joined: 2005-03-10 09:10am
- Location: Somewhere between Here and There
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
- His Divine Shadow
- Commence Primary Ignition
- Posts: 12791
- Joined: 2002-07-03 07:22am
- Location: Finland, west coast
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?
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.