# A little ASP help, please

**URL:** https://boards.straightdope.com/t/a-little-asp-help-please/119111
**Category:** Factual Questions
**Created:** [July 15, 2002, 8:37pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111 "2002-07-15T20:37:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [July 15, 2002, 8:37pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/1 "2002-07-15T20:37:57Z")

</div>

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:

```auto

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:

```auto

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?

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [July 15, 2002, 8:47pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/2 "2002-07-15T20:47:30Z")

</div>

Shoot, could a kindly mod fix that unruly line?

---

<div class="post-metadata">

### Author: ![DarrenS](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@DarrenS](https://boards.straightdope.com/u/DarrenS)
#### Post date: [July 15, 2002, 9:09pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/3 "2002-07-15T21:09:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [July 15, 2002, 9:17pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/4 "2002-07-15T21:17:54Z")

</div>

Hey! It worked! Sweet! Thanks a lot!

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

---

<div class="post-metadata">

### Author: ![DarrenS](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@DarrenS](https://boards.straightdope.com/u/DarrenS)
#### Post date: [July 15, 2002, 10:51pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/5 "2002-07-15T22:51:25Z")

</div>

You’re welcome 🙂

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.

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [July 15, 2002, 10:59pm UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/6 "2002-07-15T22:59:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![DarrenS](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@DarrenS](https://boards.straightdope.com/u/DarrenS)
#### Post date: [July 16, 2002, 12:31am UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/7 "2002-07-16T00:31:00Z")

</div>

ultrafilter - you can get the same error by doing an

```auto

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](http://www.aspfaq.com/show.asp?id=2112) not including it, but defining yourself only the constants you need, for performance reasons.

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [July 16, 2002, 1:46am UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/8 "2002-07-16T01:46:38Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [July 16, 2002, 2:06am UTC](https://boards.straightdope.com/t/a-little-asp-help-please/119111/9 "2002-07-16T02:06:52Z")

</div>

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?
