473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Subform connected to stored procedure cannot be sorted twice...

107 Expert 100+
I have a subform connected to a stored procedure in SQL Server. I can sort it once, but when I try to sort it a second time I get an error 'Data provider could not be initialized'.

The code to link the subform to the stored procedure is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.     Dim com As ADODB.Command
  4.     Dim rst As ADODB.Recordset
  5.  
  6.     Set com = New ADODB.Command
  7.     With com
  8.         .ActiveConnection = CONNECTION
  9.         .ActiveConnection.CursorLocation = adUseClient
  10.  
  11.         .CommandText = "spCorpGroupOrgStructure"
  12.         .CommandType = adCmdStoredProc
  13.         .Parameters.Refresh
  14.         .Parameters("@intOwnedCompanyID") = Me.intCompanyID
  15.  
  16.         Set Forms!frmCorpGroupOwnership.[Owned Companies].Form.Recordset = .Execute
  17.     End With
  18.  
  19. End Sub
  20.  
Any ideas on how to fix this?
Jul 26 '10 #1
2 2268
jimatqsi
1,271 Expert 1GB
Add some error handling, maybe one of these statements prior to the .execute is failing and you have no notification of that.

Also you need to close the connection and cleanup
Add
Expand|Select|Wrap|Line Numbers
  1. com.close
  2. set com = nothing
Jul 26 '10 #2
Steven Kogan
107 Expert 100+
@jimatqsi
Thanks. The data error comes up during a sort or when choosing 'Refresh All'. I've caught the error in the Form_Error event. The Current event doesn't come up with any errors.

I ended up using a pass-through query, modifying the command text with vba on the current event of the main form. The subform connects to the pass-through query which allows for multiple sorts just as if it is a regular query. It runs slower than the previous solution, but at least the error doesn't occur.
Jul 26 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mónica | last post by:
I am trying to store the turn out of a stored procedure in a temporary table to make filters. I do it of the following way: SELECT a.* FROM OPENROWSET('SQLOLEDB', 'servidor';'user';'pwd' , 'EXEC...
4
by: Robin Tucker | last post by:
Hi, I'm trying to determine with my program whether or not a given database supports a given feature set. To do this I'm querying for certain stored procedures in the sysobjects table and if...
9
by: joun | last post by:
Hi all, i'm using this code to insert records into an Access table from asp.net, using a stored procedure, called qry_InsertData: PARAMETERS Long, Long, Text(20), Long, DateTime; INSERT...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
2
by: Chris | last post by:
In SQL 2005 I have a stored procedure as below: @sub_no smallint OUTPUT BEGIN BEGIN TRANSACTION INSERT...INTO
0
by: Riaaaa | last post by:
Hi frdz, I have created the form for entering the company details with its general information in asp.net C# 2005. I want to put the validation that the user cannot enter the same name...
1
by: Lin100 | last post by:
Access ADP and Stored Procedure Did not Return Any Records Access 2002 and SQL 2000 Server I have a form named "Selector", and it have four combo boxes and a subform named...
4
by: gamaz | last post by:
Hi, I am trying to work on a stored procedure that will work with multiple database. I have a prototype of multiple databases. Those are named as the following: ts2_aldkm_app, ts2_aldkp_app,...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: chichbong | last post by:
I have a form in an .adp file in Access 2007, and the project is connected to SQL Server 2005. The form uses a stored procedure to display records. The stored procedure does a JOIN of 2 tables, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.