Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / September 2003



Tip: Looking for answers? Try searching our database.

ADODB Connection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JW - 27 Sep 2003 15:37 GMT
Could anybody tell me please what the "1,2"   refers to in the last line of
this code and where I can get a list of the parts to this '.open' argument?

~~~
set conn=server.createobject("ADODB.Connection")
set rsuser=server.createobject("ADODB.Recordset")
strMDBpath = Server.MapPath("dbname.mdb")

conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & strMDBPath

strsql = "SQL STRING HERE"

rsuser.open strsql,conn,1,2
~~~
Thanks

jon
Bob Barrows - 27 Sep 2003 16:06 GMT
> Could anybody tell me please what the "1,2"   refers to in the last
> line of this code and where I can get a list of the parts to this
> '.open' argument?

<snip>
> rsuser.open strsql,conn,1,2
> ~~~
> Thanks
>
> jon

Actually, a very important argument is missing: the 5th <options> argument,
where the command type and execution options are specified. The statement
should look like this:
rsuser.open strsql,conn,1,2, 1

The third argument (1) specifies the cursor type, with 1 corresponding to
adOpenKeyset, an expensive cursor type which is usually not needed in asp
code.

the 4th argument (2) specifies the lock type, with 2 corresponding to
adLockPessimistic - it is highly recommended that you do not use this
locktype in asp applications that need to support more than 2-3 users.

As said above, the 5th argument is used to specify the commandtype and
execute options. You should specify these rather than making ADO guess. It
will improve performance. My suggested argument, 1, corresponds to the
adCmdText command type, which is what should be used when passing a string
containing a sql statement to the database.

Your code will be better documented if you use the ADO constants rather than
the numbers. See http://www.aspfaq.com/show.asp?id=2112 for a good technique
to use to expose the ADO constants in your pages. Using constants, this line
of code would look like this:

rsuser.open strsql,conn,adOpenKeyset,adLockPessimistic,  _
   adCmdText

The benefit, of course, is that you don't have to look up what the numbers
mean.

Go here for the ADO documentation:
http://msdn.microsoft.com/library/en-us/ado270/htm/adostartpage1.asp

For your specific question, see here:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdamth03_2.asp

HTH,
Bob Barrows
TJS - 27 Sep 2003 16:44 GMT
these are ado constants

http://www.aspin.com/func/search?cob=aspkey&qry=ADO+constants
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.