Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / July 2003



Tip: Looking for answers? Try searching our database.

Opening Recordset. Which way is better?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MAB - 31 Jul 2003 10:06 GMT
1.      com.commandtext = sql_query
        Set  Rs = com.execute

2.       Rs.Open  sql_query, myConnection

Is there any difference?
Phill.  W - 31 Jul 2003 11:10 GMT
> 1.      com.commandtext = sql_query
>          Set  Rs = com.execute
>
> 2.       Rs.Open  sql_query, myConnection
>
> Is there any difference?

Do you hammer nails with a spanner?  No.

Read data into a [configured] recordset object, execute [raw]
commands through a connection object. You get a lot more control
over the recordset if you have a recordset object to play with in the
first place - without it, you have to put up with the defaults, which are
often /not/ want you need.

HTH,
   Phill  W.
Graham Dobson - 31 Jul 2003 16:23 GMT
> commands through a connection object. You get a lot more control
> over the recordset if you have a recordset object to play with in the
> first place - without it, you have to put up with the defaults, which are
> often /not/ want you need.

Agreed, but if you just need to read a value or something similarly limited
(or control your update/insert functionality) encapsulating your data
manipulation through methods which use parameterised command objects can be
a good design approach.  -- Graham
Samuel Hon - 31 Jul 2003 19:36 GMT
It depends what you're trying to do

Option 1 makes the recordset read-only and you can only go forward
through the recordset. You cant do .RecordCount on it. However, its
better for parametereized (did I spell that right??!!) queries I
believe

Option 2 allows you to have other recordset options and is ideal for
opening simple queries.

If however, you are doing updates, deletes or inserts where you're not
returning a recordset, then just use the ADODB.Command object

com.commandtext = sql_insert_update_or_delete
com.execute

No point retrieving a recordset if you're not going to use it.

> 1.      com.commandtext = sql_query
>          Set  Rs = com.execute
>
> 2.       Rs.Open  sql_query, myConnection
>
> Is there any difference?
 
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.