473,394 Members | 1,739 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,394 software developers and data experts.

Troubleshooting with MS SQL stored procedures

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 1416
jimatqsi
1,271 Expert 1GB
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 Expert Mod 4TB
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 Expert Mod 4TB
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 Expert 1GB
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 Expert Mod 4TB
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.