469,936 Members | 2,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

A question about shared db connections

Hi and Thanks in advance for taking a look at my question.

I am using an "include" page with a sub to open a db connection for multiple
Recordsets. My problem is that in some cases I need to use set connection
parameters such as adOpenDynamic, adLockPessimistic, adCmdText.

Is there a way to add these to the "Open Data Connection Command" or to the
"Open Recordset Command"?

Examples Follow
**** Included File ******

'******* Open Connection to MyData
Sub Opendata( DatCon )
Set DatCon = Server.CreateObject("ADODB.Connection")
DatCon.Open "DSN=data04;"
End Sub

'******* Close Connection to MyData
Sub CloseData( DatCon )
Set DatCon = NOTHING
End Sub

'******* Open Recordset from DatCon
Sub OpenRs( Sql, rs )
Set rs = DatCon.Execute(Sql)
End Sub

'******* Close Recordset from DatCon
Sub CloseRs( rs )
Set rs = NOTHING
End Sub

********** Original Page info************

Sql = "SELECT * FROM p_CurrentUpdate WHERE CustId = " & StrCusId & " ORDER
BY Timestamp ASC"
OpenRs Sql, rs
StrCurrentUpdate = "True"
If rs.EOF Then
StrCurrentUpdate = "False"
StrCustUpdateLast = rs.Fields("Timestamp").Value
End If
CloseRs rs


When I execute this code I get [Microsoft][ODBC Microsoft Access Driver] Too
few parameters. Expected 1.

Now, all the Variables and Objects are "Dim" at the top of the page, and if
I don't use the ORDER BY parameter it will work, so I am pretty sure it is
because the proper parameters are not set for DatCon and record interaction.

Please give any assistance you can. Thank you


Jul 19 '05 #1
1 1407
Already answered over in .db

Please do not multipost William. This is definitely a database-related
question so .asp.db was the perfect group in which to post it. Posting it
here as well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his time
to answer it here, only to find that it was already resolved in the other
group, that person may have been annoyed enough to ignore any future posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most appropriate
(again, this was not one of them), and you will want to post a question to
both groups. In that situation, you should use the cross-posting technique,
rather than posting multiple postings of the same message. To crosspost, put
a semicolon-delimited list of the newsgroups to which you wish to post in
the To: header of your post and post it once. It, and any replies to it,
will appear in all the newsgroups in your list. So, if I reply in .asp.db,
my reply will also appear here in .asp.general.

Bob Barrows

Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mudge | last post: by
11 posts views Thread by Mike MacSween | last post: by
3 posts views Thread by Michael | last post: by
5 posts views Thread by Rahul Anand | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.