Connecting to MS Access 2000 DB from ASP

I am trying to connect to an MS Access DB from ASP and have a strange situation!

My connection string is as follows:
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<Path to MDB>;"

I have tried the following connection strings as well, just to make sure I connect properly:
objConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=<Path to MDB;" AND
objConn.Open "FILEDSN=<Path to DSN connection file"
The result is always the same.

After executing this statement, I check the state of the connection object. The value of
objConn.State is 1, which means the connection is open. Still, I get the following error:
Error Number: 3001
Error Description: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Error Source: ADODB.Connection

To further test the connection, I create a recordset object and use this connection to execute a SQL statement. The statement executes correctly and brings back results too! Now, if I check the Err object, it still gives the same error as above.

Any ideas what the error could be for and how to correct it?      
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

probably the error object is not cleared from a previous error. try reseting the error object using Err.Clear before you try to create the new connection and then check if err.description is still set to the same value. Hope you are not using on error resume next?

Have Fun!
If you are using On error resume next, you can check after the connection opens for the error.  I put the sql statement into a string to it can be reported to the error page for debugging  purposes.  This is handy especially if you build them on the fly.

Here's an example:
On Error Resume next

Dim DSNtemp
Dim sqlstmt
Set objConn = server.CreateObject("adodb.connection")

DSNTemp = "DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;"
DSNTemp = DSNTemp & "DBQ=" & server.MapPath("yourDatabase.mdb")
objConn.Open DSNtemp

if err.number <> 0 then
    Response.Write("An error has occured opening the connection.<br><br>" & vbcrlf)
    Response.Write("Error Number:" & err.number & "<br>" & vbcrlf)
    Response.Write("Error Description:" & err.description & "<br>" & vbcrlf)
end if

Set rs = Server.CreateObject("ADODB.Recordset")

sqlstmt = "SELECT * from YOUR_TABLE"
Set rs = conn.execute(sqlstmt)

if err.number <> 0 then
    Response.Write("An error has occured executing a SQL statement.<br><br>" & vbcrlf)
    Response.Write("Error Number:" & err.number & "<br>" & vbcrlf)
    Response.Write("Error Description:" & err.description & "<br>" & vbcrlf)
    Response.Write("Extra Info:  " & sqlstmt)
end if


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sorabharoraAuthor Commented:
Hi Guys

Thanks for your responses. I was out of office yesterday, so saw the comments just now. I did have a On Error Resume Next statement in my code. I removed that and called the page to test. It gave me a more helpful error with the line number.
The problem was that I was trying to set the CursorLocation property for the Connection object. I guess that is not valid for Access databases. I commented that out and the problem got solved.

Thanks for giving me the right pointer to look at!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.