W
W1ld0ne [MCSD]
This is why programmers give up being programmers and become Belly dancers or scuba diving instructors.
The problem explained:
1.. This code works in a production site in a COM+ component built in VB6 using MDAC 2.7. (Well a slightly more complicated version of it... but none-the-less.)
2.. This code is about as simple as it gets.... (Driving me insane!!!)
3.. I am trying to make this work in a .Net class library.
4.. I am currently using ADODB.Net but I have substituted ADODB 2.7 (Microsoft ActiveX Data Objects 2.7) (Still nothing)
5.. I have also included the stored procedure (Rocket science bit there) to this post, in case I am doing something really stupid at that step.
6.. The stored proc fires perfectly in MS SQL Query Analyser.
7.. From this code, called from another .Net Windows Application, ALWAYS RETURNS DBNULL on the output parameter.
8.. Even Parameter 0 (Default return parameter) returns NOTHING
Please, please, please tell me what I am doing wrong!!!
Thanks
David Taylor
Ps. help!!!
The offending Method:
Public Function ExecStoredProc(ByVal StoredProc As String) As String
Try
Dim cmStoredProc As New ADODB.Command
With cmStoredProc
.ActiveConnection = cnSQLAO
.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
.CommandText = StoredProc
.Parameters(1).Type = ADODB.DataTypeEnum.adVarChar
.Parameters(1).Size = 50
.Execute()
End With
Return (cmStoredProc.Parameters(1).Value)
cmStoredProc = Nothing
Catch ex As Exception
ex.Source = TypeName(Me) & ": ExecStoredProc(" & ex.Source & ")"
Throw ex
End Try
End Function
The Really complicated SQL 2000 Stored Procedure in question:
CREATE PROCEDURE [dbo].[sp_CheckAccess]
@Result VARCHAR(50) OUTPUT
AS
SELECT @Result = 'Hello World!'
RETURN(1)
The problem explained:
1.. This code works in a production site in a COM+ component built in VB6 using MDAC 2.7. (Well a slightly more complicated version of it... but none-the-less.)
2.. This code is about as simple as it gets.... (Driving me insane!!!)
3.. I am trying to make this work in a .Net class library.
4.. I am currently using ADODB.Net but I have substituted ADODB 2.7 (Microsoft ActiveX Data Objects 2.7) (Still nothing)
5.. I have also included the stored procedure (Rocket science bit there) to this post, in case I am doing something really stupid at that step.
6.. The stored proc fires perfectly in MS SQL Query Analyser.
7.. From this code, called from another .Net Windows Application, ALWAYS RETURNS DBNULL on the output parameter.
8.. Even Parameter 0 (Default return parameter) returns NOTHING
Please, please, please tell me what I am doing wrong!!!
Thanks
David Taylor
Ps. help!!!
The offending Method:
Public Function ExecStoredProc(ByVal StoredProc As String) As String
Try
Dim cmStoredProc As New ADODB.Command
With cmStoredProc
.ActiveConnection = cnSQLAO
.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
.CommandText = StoredProc
.Parameters(1).Type = ADODB.DataTypeEnum.adVarChar
.Parameters(1).Size = 50
.Execute()
End With
Return (cmStoredProc.Parameters(1).Value)
cmStoredProc = Nothing
Catch ex As Exception
ex.Source = TypeName(Me) & ": ExecStoredProc(" & ex.Source & ")"
Throw ex
End Try
End Function
The Really complicated SQL 2000 Stored Procedure in question:
CREATE PROCEDURE [dbo].[sp_CheckAccess]
@Result VARCHAR(50) OUTPUT
AS
SELECT @Result = 'Hello World!'
RETURN(1)