473,545 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
+ 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.Reco rdset = 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 1431
jimatqsi
1,273 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,273 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
3508
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 beginning to build up in number, so I'm wondering if it's possible to search in Query Analyzer for stored procedures that contain certain words / phrases...
17
2178
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
10726
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 execute in the database server with better performance? Please advise good references for Oracle stored procedures also. thanks!!
2
2796
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 code in stored procedures (im advocating encryption of them). When deploying an application however stored procedure seem to add another level of...
0
1330
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 can be imported by other people with the least amount of work. I have been exporting the stored procedures from the DB2 Development Center to a zip...
2
9205
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 problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
5
3461
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 Procedures. I thought stored pricedures were an Oracle/MS SQL Server thing and don't know how they work with Access Jet. I've looked at some of...
45
3372
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
72365
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 2005 Test Environments. What is the purpose of a view if I can just copy the vode from a view and put it into a stored procedure? Should I be...
12
4447
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 completes procedure and returns result server: Microsoft SQL Server 2000 - 8.00.818 (Intel X86) Microsoft Corporation Enterprise Edition on Windows NT...
0
7478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5984
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4960
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.