Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 disconnected recordsets

Author  Topic 

sqlmom
Starting Member

5 Posts

Posted - 2003-06-05 : 12:25:01
I'm learning to create and use disconnected recordsets with ADO in VB6 and see how nifty it is, but I want to understand the implications and possible drawbacks. Can anyone answer these questions?

1) If I only want to use the data in the recset, but not change it, is there a preferred way to get it (and still be disconnected)?

2) Must you always use: adUseClient, adOpenForwardOnly, adLockBatchOptimistic?

3) If you use adUseClient, adOpenForwardOnly, adLockBatchOptimistic, and you don't update the recordset, is that bad?

Now those were all pretty much the same question, but how about this:

4) I have a disconnected recset which is the result of a join from 2 tables. I want to add a record to the recset but only want to effect 1 table. Is there a way either via ADO or by way of sql table/column config?

Thanks anyone out there who can help.

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-06-05 : 12:49:33
Questions 1,2,3 & 4: Its best that you do not use the ADO recordsets to update data. Use stored procedures, they are faster, (a lot) less prone to locking problems and secure.

Creating disconnected recordsets is easy:

Dim cnn as new ADODB.Connection
Dim rs as new ADODB.Recordset

cnn.ConnectionString = "blah"
cnn.Open

rs.CursorLocation = adUseClient
rs.Open "SQL Select String here", cnn, adOpenSnapshot, adLockReadOnly
set rs.ActiveConnection = Nothing


You can use the recordset for as long as you want. Since you will not be doing any updates, you can set the locking behaviour to adLockReadOnly. And client side cursors cannot be forward-only, they are always scrollable. So you can safely use adOpenSnapshot.

Owais





Edited by - mohdowais on 06/05/2003 12:50:21
Go to Top of Page

biswajitdas
Starting Member

44 Posts

Posted - 2003-06-12 : 03:41:35
quote:

Questions 1,2,3 & 4: Its best that you do not use the ADO recordsets to update data. Use stored procedures, they are faster, (a lot) less prone to locking problems and secure.

Creating disconnected recordsets is easy:

Dim cnn as new ADODB.Connection
Dim rs as new ADODB.Recordset

cnn.ConnectionString = "blah"
cnn.Open

rs.CursorLocation = adUseClient
rs.Open "SQL Select String here", cnn, adOpenSnapshot, adLockReadOnly
set rs.ActiveConnection = Nothing


You can use the recordset for as long as you want. Since you will not be doing any updates, you can set the locking behaviour to adLockReadOnly. And client side cursors cannot be forward-only, they are always scrollable. So you can safely use adOpenSnapshot.

Owais





Edited by - mohdowais on 06/05/2003 12:50:21



hi i want do everything in sql
i want make it in my tips
Go to Top of Page

biswajitdas
Starting Member

44 Posts

Posted - 2003-06-12 : 03:44:44
hi
i am das.i gone through your question.would you elaborate the question.
dissconeted recordset is faster and alway u use client side cursor in that case


hi i want do everything in sql
i want make it in my tips
Go to Top of Page
   

- Advertisement -