| Author |
Topic |
|
adweigert
Starting Member
22 Posts |
Posted - 2003-09-17 : 14:55:23
|
I have a slight problem, a stored procedure isn't returning any results when called from within a VB COM object using ADODB. However, if I run the same SQL string in Query Analyzer the results are returned as expected.The stored procedure is attrocious - the developer came from an informix background where cursors are common places - however it works - the code is too complex to simple re-write unfortunately but that's my next option if this can't be resolved by anyone. The code to call it is quite simple, infact since I didn't write this code originally - I inherited it - I thought perhaps there was a configuration issue so I created this VERY simple example to try and track down why the Recordset is being returned closed. Dim objCmd As ADODB.Command Dim objCn As ADODB.Connection Dim objRs As ADODB.Recordset Set objCn = New ADODB.Connection Call objCn.Open("Provider=SQLOLEDB;Server=LOCALHOST;UID=stars;PWD=stars;Database=stars;") Set objCmd = New ADODB.Command With objCmd .CommandText = "PROC_TransWorkflow" .CommandType = adCmdStoredProc Set .ActiveConnection = objCn Call .Parameters.Refresh .Parameters.Item("@select") = "wtt" .Parameters.Item("@user") = "ADWeigert" .Parameters.Item("@keyId") = 4 .Parameters.Item("@durationMinutes") = 0 Set objRs = .Execute() End With ' Catch the Recordset not being open when it should be Debug.Assert objRs.State = adStateOpen If objRs.State <> adStateClosed Then Call objRs.Close End If Set objRs = objCn.Execute("EXEC PROC_TransWorkflow " & _ "@durationMinutes=0," & _ "@user='ADWeigert'," & _ "@keyId=4, @select='wtt'") ' Catch the Recordset not being open when it should be Debug.Assert objRs.State = adStateOpen If objRs.State <> adStateClosed Then Call objRs.Close End If If objCn.State <> adStateClosed Then Call objCn.Close End If Set objCmd.ActiveConnection = Nothing Set objCn = Nothing Set objCmd = Nothing Set objRs = NothingThe second objCn.Execute string is the one that works when I run in Query Analyzer. Neither of these attempts work. I'm 100% sure that this is the parameter set that the application is trying to pass in - I debugged to the execution point to extract the parameters and compared them with the SQL Profiler parameters being passed.My environment is: Windows XP Professional, Visual Basic 6 SP5, IIS 5 with COM+ 1.5. I have tried using ADODB v2.1, 5, 6, and 7 with no luck. Any ideas? Sorry for posting this in this forum if it is not the correct one, I'm just desperate to resolve this. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-09-17 : 15:15:08
|
| did you try the setting the parameters without the @ symbol?do you get an error message? that would be helpful !- Jeff |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2003-09-17 : 15:16:15
|
Have you tried running profiler to see what is actually being executed?I think you might need to turn on named Parameters. Like thisWith objCmd .NameParameters = trueEnd With Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
adweigert
Starting Member
22 Posts |
Posted - 2003-09-17 : 15:25:36
|
quote: Originally posted by jsmith8858 did you try the setting the parameters without the @ symbol?do you get an error message? that would be helpful !
It didn't like the parameters without the @ symbol. This works fine in the same procedure with different parameter values.Nope, no error messages, the Recordset is just closed. |
 |
|
|
adweigert
Starting Member
22 Posts |
Posted - 2003-09-17 : 15:27:00
|
quote: Originally posted by MichaelP Have you tried running profiler to see what is actually being executed?I think you might need to turn on named Parameters. Like thisWith objCmd .NameParameters = trueEnd With
I did run profiler, I copied the SQL execution string straight from profiler and it worked fine.NameParameters ? I remember something like that in ADODB but I haven't done this stuff in ages. |
 |
|
|
adweigert
Starting Member
22 Posts |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2003-09-17 : 15:50:25
|
| addSET NOCOUNT ONat the begining of the procedure |
 |
|
|
adweigert
Starting Member
22 Posts |
Posted - 2003-09-17 : 15:52:57
|
| You've come across this then :) You are my hero, seriously ... I obviously didn't check the procedure enough to see that that wasn't turned on ... Now on to the bigger problem... why would this work on a windows 2000 pro machine with ADODB 2.5 and not windows xp pro with ADODB 2.5 ? I believe I have also come across this problem on another windows 2000 pro machine ... |
 |
|
|
simondeutsch
Aged Yak Warrior
547 Posts |
Posted - 2003-09-17 : 22:38:43
|
| Why would what work? Does the app work only on a Win2K machine (I assume running SQL locally) and not on a WinXP Pro machine (I assume running SQL locally)? What exactly is the problem, the recordset not returning on a WinXP machine with the SET NOCOUNT ON/SET NOCOUNT OFF lines in the stored procedure?Sarah Berger MCSD |
 |
|
|
adweigert
Starting Member
22 Posts |
Posted - 2003-09-18 : 08:13:05
|
| Working environments:Development machine:Windows 2000 Professional SP3ADODB 2.5VB6 SP5IIS 5USING SQL Server 2000Production:Windows NT 4 SP6aIIS 4ADODB 2.5USING SQL Server 7Whenever I tried to put it on another workstation with Win2k or WinXp I was experiencing this issue. Sadly the programmer coded it as not to throw errors when data is not returned when it is required/expected... so it would just make the web application appear not to work fully.The stored procedures ended up with half having the SET NOCOUNT ON statement and the other half did not. I added it to the half that didn't and all is well now. |
 |
|
|
|