all groups > inetserver asp db > september 2003 >
You're in the

inetserver asp db

group:

ADODB Connection


Re: ADODB Connection TJS
9/27/2003 8:44:48 AM
inetserver asp db:
these are ado constants

http://www.aspin.com/func/search?cob=aspkey&qry=ADO+constants

Re: ADODB Connection Bob Barrows
9/27/2003 11:06:25 AM
[quoted text, click to view]

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

ADODB Connection JW
9/27/2003 2:37:23 PM
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

AddThis Social Bookmark Button