Re: using adOpenDynamic
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Tue, 5 Jul 2005 15:40:33 -0400
Kevin wrote:
> Hi,
>
> I have an Access2000 db, IIS5.
>
> In an attempt to get back to basics, I am going thru a beginning ASP
> databases book by wroX -- and this piece of code is suppose to work
> according to the book -- and I cannot get it to work -- all I get is
> a blank page -- no errors:
>
>
> <%
> strDBPath = Server.MapPath("/xxx/xx/zzz/ddd.mdb")
> Set cnnSimple = Server.CreateObject("ADODB.Connection")
'with IIS 5+ you no longer need to use the Server.CreateObject. Using
vbscript's CreateObject will improve performance:
Set cnnSimple = CreateObject("ADODB.Connection")
> cnnSimple.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> strDBPath & ";"
>
> dim adCmdStoredProc, adOpenDynamic
> adCmdStoredProc = 4
> adOpenDynamic = 2
>
> Set objCmd = Server.CreateObject("ADODB.Command")
> set objCmd.ActiveConnection = cnnSimple
> objCmd.CommandText = "qryRequests"
> objCmd.CommandType = adCmdStoredProc
>
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.open objCmd, , adOpenDynamic
>
<snip>
> any thoughts
With Jet, you do not need a Command object. Why do you want a dynamic
cursor? Are you really pllanning for this page to be processing long enough
for changes/deletions by other users to matter? If so, you are creating a
non-scaleable application. An asp page should do its job in less than a few
seconds. Are you sure a default forward-only cursor won't do the job for
you?
Try this:
Set objRS = CreateObject("ADODB.Recordset")
cnnSimple.qryRequests objRS
if not objRS.EOF then
Do While Not objRS.EOF
Response.Write objRS("reqTitle") & _
" <b>--</b> " & objRS("requestor") & "<br>"
objRS.MoveNext
Loop
else
response.write "Recordset was empty"
end if
If you really need an expensive dynamic cursor for some reason, do this:
Set objRS = CreateObject("ADODB.Recordset")
objRS.cursortype=adOpenDynamic
cnnSimple.qryRequests objRS
if not objRS.EOF then
Do While Not objRS.EOF
Response.Write objRS("reqTitle") & _
" <b>--</b> " & objRS("requestor") & "<br>"
objRS.MoveNext
Loop
else
response.write "Recordset was empty"
end if
You may want to look into alternatives for recordset loops:
http://www.aspfaq.com/show.asp?id=2467
Here is some more information about executing saved queries/stored
procedures via ADO/ASP (some of these are redundant):
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&selm=eHYxOyvaDHA.4020%40tk2msftngp13.phx.gbl
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&selm=ukS%246S%247CHA.2464%40TK2MSFTNGP11.phx.gbl
http://www.google.com/groups?selm=eETTdnvFDHA.1660%40TK2MSFTNGP10.phx.gbl&oe=UTF-8&output=gplain
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=e6lLVvOcDHA.1204%40TK2MSFTNGP12.phx.gbl
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is
my spam trap, so I don't check it very often. You will get a quicker
response by posting to the newsgroup.
.
- Follow-Ups:
- Re: using adOpenDynamic
- From: Ken Schaefer
- Re: using adOpenDynamic
- Prev by Date: Re: SP Problem , PLZ HELP
- Next by Date: Re: SP Problem , PLZ HELP
- Previous by thread: SP Problem , PLZ HELP
- Next by thread: Re: using adOpenDynamic
- Index(es):
Relevant Pages
|
|