A little ASP help, please

I need some help designing a website that uses IIS and ASP to provide an interface to a MS Access database (it’s Access XP, if that makes any difference).

Basically, I can get a read-only recordset just fine. But I can only open recordsets read only, and it’s driving me mad. I want to be able to update data using the website, y’know?

Here’s the code I’m using to try to get the recordset:


strFilepath = ...

strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open strConnString

strSQL = ...
Set rstRecords = Server.CreateObject("ADODB.Recordset")
rstRecords.Open strSQL, cnn, adOpenDynamic, adLockBatchOptimistic

The lock type is irrelevant–anything other than adLockReadOnly gets me the following error message:


Error Type:
ADODB.Recordset (...)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

It’s pointing to the line that starts “rstRecords.Open…”, claiming that that’s the problem.

Any clue as to what might be going on here?

Shoot, could a kindly mod fix that unruly line?

Just a shot in the dark - try hard-coding the values for the Open parameters, instead of using the constants from adovbs.inc.

Hey! It worked! Sweet! Thanks a lot!

Now I’ve just gotta figure out why the damn thing works…

You’re welcome :slight_smile:

I’m wondering if the particular adovbs.inc you’re using doesn’t define correctly (or at all) either adOpenDynamic or adLockBatchOptimistic; in that case, if you are not using “Option Explicit”, ASP will happily treat them as = 0, generating the error you saw.

It could also be that you are not including adovbs.inc at all - the constant values would default to 0 (being undefined) which might work only with read-only options through some weird logic.

The only thing against that is that it would allow to me to open the recordset with any type of cursor, so long as it was read-only. Oh well, it’s working now. Thanks once again.

ultrafilter - you can get the same error by doing an


rstRecords.Open strSQL, cnn, 0,0

which leads me to think you haven’t included adovbs.inc - VBScript is defaulting the variables to 0 since they aren’t defined. As you say, it is strange that it only works with adLockReadOnly - perhaps this constant is defined in your ASP file elsewhere, or in an included file, but the other constants are not?

I’d strongly recommend you to use “Option Explicit” to catch typos and situations like this - believe me, you’ll be glad you did in the long run.

Regarding adovbs.inc itself - some people recommend not including it, but defining yourself only the constants you need, for performance reasons.

Yeah, I’ll just include it. This is an intranet page, and will be accessed by about 30 people, so performance isn’t a huge problem. Thanks once again.

That is, I’ll include it to get the page up and running, and then figure a better way around the problem once I get a little further along. I don’t wanna come off as a hack programmer.

There’re no constants defined, and no include files, so there’s no good reason why adLockReadOnly or any of the cursor constants should work and adLockPessimistic wouldn’t. Weird, huh?