Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ADO Recordset Clone and ADO Provider

Posted on 1999-07-28
11
Medium Priority
?
401 Views
Last Modified: 2013-12-25
I am using Microsoft OLEDB Provider for ODBC. I have used the default provider and also SQLOLEDB.1
I simply cannot do
Set rsA = rsB.Clone

I absolutely need to do this to get a recordcount.

I am using VB6, ADO and SQL Server 7
0
Comment
Question by:mfarid1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 

Author Comment

by:mfarid1
ID: 1507211
The message I get is something like, This feature is not supported by my provider
0
 
LVL 7

Expert Comment

by:simonsabin
ID: 1507212
Use the MSDASQL provider. It works fine for me my connect string is
"Provider=MSDASQL.1;Connect Timeout=15;Extended Properties="DRIVER=sql server;SERVER=uk-ins-fs18;UID=sa;PWD=;APP=Visual Basic;WSID=INS573;DATABASE=GarwynApp";Locale Identifier=2057"
I have got latest Data access Components sql server odbc driver 3.7
0
 

Author Comment

by:mfarid1
ID: 1507213
Same Error. This is what I get:

Run-time Error 3251
The operation requested by the application is not supported by the provider.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Expert Comment

by:simonsabin
ID: 1507214
What version of ODBC drivers do you have?
0
 

Author Comment

by:mfarid1
ID: 1507215
3.70.06.90 SQLSRVR32.DLL 4/1/99
0
 
LVL 2

Accepted Solution

by:
enkay022798 earned 400 total points
ID: 1507216
Have you tried disconnecting the recordset from the connection. I use the same driver but use disconnected recordsets and it works pretty fine.

Also, what are he properties of the connection and the recordset object?
0
 

Author Comment

by:mfarid1
ID: 1507217
What do you mean by disconnecting? do you mean setting the connection to nothing?

I tried it and it did not work:

I got the recordset with the data.

Dim rsA As ADODB.Recordset
Dim rsB As ADODB.Recordset

Set rsA = ('Get recordset from SQL')
cn.Close

Set rsTemp = rsA.Clone

I get the following error:
Run-time error 3704

The operation requested by the application is not allowed if the object is closed.

0
 
LVL 2

Expert Comment

by:enkay022798
ID: 1507218
Disconnecting is not setting the connection object to nothing. I am pasting the corrected code from your example

       Dim rsA As ADODB.Recordset
       Dim rsB As ADODB.Recordset

       Set rsA = ('Get recordset from SQL')
       ' cn.Close --> this is wrong
       set rsA.ActiveConnection = nothing  ' this will disconnect the recordset from the connection

       Set rsTemp = rsA.Clone ' now this should work

You also need to do the following stuff to disconnect a recordset

      CursorLocation should be client side
      CursorType should be Static
      LockType should be UpdateBatchOptimistic

You can reconnect the recordset to the connection object mush the same way after you finish processing the data in it

     set rsA.ActiveConnection = cn

And then fire the Update or UpdateBatch method to committ your changes

Hope this works for you. I can assure you that it will. LEt me know if you need any more info or have any more problems with this.

Regards,
enkay.
0
 

Author Comment

by:mfarid1
ID: 1507219
Does not work.

I have tried the following:

Dim rsA As ADODB.Recordset
Dim rsB As ADODB.Recordset
Note: pConn is a previous active connection

rsADO.Open "sp_Tables", pConn, adOpenStatic, adLockBatchOptimistic, adCmdStoredProc
'The above statement works fine

'Tried this FIRST
Set rsB = rsA.Clone

'Get this error message:
'Run-time error 3251
'The operation requested by the application is not 'supported by the provider

'Tried this SECOND
Set rsA.ActiveConnection = Nothing
'Get the following error:
'Run-time error 3705
'The operation requested by the application is not allowed 'if the object is open

'Tried this THIRD
rsA.Close
Set rsA.ActiveConnection = Nothing
Set rsB = rsA.Clone
'Get the following error:
'Run-time error 3704
'The operation requested by the application is not allowed 'if the object is closed on the last line

The stored proc I am trying to execute is a stored proc that comes with SQL Server named 'sp_Tables'. If you can send me some code as how that stored procedure can be made to work and get a recordcount then I would greatly appreciate it. If I can provide any other information, please let me know.
0
 
LVL 2

Expert Comment

by:enkay022798
ID: 1507220
Are you haveing a Client side cursor? If the connection is opened using server side cursors it will override whatever similar properties that you will define for any object (command , recordset etc) that uses that connection. Can you give me the connection string and the connection object properties that you are having at the time you execute the above code.

I am using this all through my applications and it works just fine. And I am using SQL server as the backend as wll. There must be some property which is not getting a proper value due to which you are not able to disconnect.
0
 

Author Comment

by:mfarid1
ID: 1507221
enkay, you are the man. It worked!!! Actually, the only thing I needed to do was use a CursorLocation of adUseClient on the Connection, not on the recordset or the command object. Its amazing how long this took me and how few people know about this.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question