473,473 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Troubleshooting with MS SQL stored procedures

1 New Member
hi, have a procedure that needed amending and thus required another parameter. My inital VBa code to run this procedure was:

Expand|Select|Wrap|Line Numbers
  1. Dim rs As ADODB.Recordset
  2. GetData rs, "sp_TM_GetCurrentRoleTasks", Me.cboRole
  3. Set Me.cboTask.Recordset = rs
  4.  
  5. the middle line changed to: 
  6. GetData rs, "sp_TM_GetCurrentRoleTasks ", CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
  7.  
  8. the Get Data function which had been working fine is:
  9. Public Sub GetData(ByRef rsIn As ADODB.Recordset, strProc As String, Optional strArgs As String)
  10. Dim cn As ADODB.Connection
  11.  
  12.         Set cn = New ADODB.Connection
  13.         cn.ConnectionString = "Provider=sqloledb;Data Source=IUDATA.hscni.net;Initial Catalog=USERS;Trusted_Connection=Yes"
  14.         cn.Open
  15.  
  16.         Set rsIn = New ADODB.Recordset
  17.         With rsIn
  18.              Set .ActiveConnection = cn
  19.             .ActiveConnection.CommandTimeout = 60
  20.             .Source = strProc & " " & strArgs
  21.             .CursorType = adOpenDynamic
  22.             .LockType = adLockPessimistic
  23.             .CursorLocation = adUseClient
  24.             .Open
  25.         End With
  26. End Sub
yet now I get an error 7965:The object you entered is not a valid recordset property on the 3 rd line:
Set Me.cboTask.Recordset = rs

The procedure runs fine in an SQL query window with the source so I don't understand why I'm getting the error.

UPdate: on further investigation, the problem is not with the parameters as I initially thought - but seems to be with the stored procedure returning rowcount messages - even with using NOCOUNT.

final update: the procedure has (suddenly) started working with NOCOUNT behaving as expected. I'm not sure what I've changed so it may be of little help to others. Thanks for trying.
Apr 14 '14 #1
5 1419
jimatqsi
1,271 Recognized Expert Top Contributor
h0pal0ng42,
Welcome to Bytes.

What version of Access are you using? I'm not familiar with the Recordset property of a combo box. I normally set the Rowsource property equal to the SQL code string.

Jim
Apr 14 '14 #2
zmbd
5,501 Recognized Expert Moderator Expert
So let's treat this as I would any other MS built in function by using named parameters:

Expand|Select|Wrap|Line Numbers
  1. Public Sub GetData(ByRef rsIn As ADODB.Recordset, strProc As String, Optional strArgs As String) 
Expand|Select|Wrap|Line Numbers
  1. So our origninal would be:
  2. GetData _
  3.    rsIn := rs, _
  4.    strProc := "sp_TM_GetCurrentRoleTasks", _
  5.    strArgs := Me.cboRole 
Expand|Select|Wrap|Line Numbers
  1. Now you have:
  2. GetData _
  3.    rsIn := rs, _
  4.    strProc := "sp_TM_GetCurrentRoleTasks", _
  5.    strArgs := CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
Now I find that most errors occur when the string is constructed within the function; thus change this:

Expand|Select|Wrap|Line Numbers
  1. Now you have:
  2. Dim zstrArgs
  3.  
  4. zstrArgs = CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
  5.  
  6. GetData _
  7.    rsIn := rs, _
  8.    strProc := "sp_TM_GetCurrentRoleTasks", _
  9.    strArgs := zstrArgs
  10.  
Add a debug.print after the zstrArgs and you will be able to tell if the string is being resolved correctly.

The next item is to address, where are your quotes for the string values? I would guess that Me.cboRole was returning a numeric value, now you're attempting to use a string value.

Then finally, did you do a debug.compile, I'll bet that chokes. Follow the basic troubleshooting steps as outlined:[*]> Before Posting (VBA or SQL) Code
Apr 14 '14 #3
zmbd
5,501 Recognized Expert Moderator Expert
jimatqsi:
The recordset property has been around for some time now.
I haven't used it much; however, you can actually use it like we do for recordsetclone on a form to do a quick search within the control.
It will also populate the control on an open recordset; however, I've found that you have to leave the recordset open or the values disappear whereas with the rowsource, the values are queried once and stay put.
Apr 14 '14 #4
jimatqsi
1,271 Recognized Expert Top Contributor
Thanks for the tip, z, that's interesting to know. I should have passed this one by as soon as I saw ADO in use. I stick to DAO whenever possible.

Jim
Apr 14 '14 #5
zmbd
5,501 Recognized Expert Moderator Expert
you can use this with dao as well it's part of the cbo object model. (^_^)
Apr 15 '14 #6

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

Similar topics

2
by: M Wells | last post by:
Hi All, I'm wondering if anyone can tell me if it's possible to search for stored procedures by their contents? I tend to leave very descriptive notes in stored procedures and they're...
17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
0
by: Tim Bolla | last post by:
I have created ~30 stored procedures that I need to have running on a database in order to use the application that I have developed. I am looking for a solution so that these stored procedures...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
5
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
12
by: mednyk | last post by:
T-SQL Debugger Doesn't Allow Stepping Through Stored Procedures And there is no other procedure with the same name owned by dbo or any other users. There is no error messages also, it just...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.