G
Guest
Im still struggling to get this executing a stored proc working .. im
running vb.net (2003) and SQL 2005.. the story thus far is with a lot of
help and a prevailing wind i have come up with the following
( CON_BOSSCONNECTION is already connected )
Dim InputString() As String
Dim ReturnValue As Integer
InputString = Split(InputParm, ";")
' set the query commands
STR_SQLCOMMAND.CommandText = "BossData.dbo.OperatorLogon"
STR_SQLCOMMAND.CommandType = CommandType.StoredProcedure
STR_SQLCOMMAND.CommandTimeout = 30
With STR_SQLCOMMAND
' set the query commands
.CommandText = "BossData.dbo.OperatorLogon"
.CommandType = CommandType.StoredProcedure
.CommandTimeout = 30
' set the connection
.Connection = CON_BOSSCONNECTION
' Set the 1st Parameter
.Parameters.Add("@OperatorName", SqlDbType.VarChar, 20).Value =
InputString(0).ToString
' Set the 2nd Parameter
.Parameters.Add("@OperatorPassword", SqlDbType.VarChar,
20).Value = InputString(1).ToString
' Set the 3rd Parameter
.Parameters.Add("@PasswordLife", SqlDbType.VarChar, 3).Value =
InputString(2).ToString
' Set the returned Paramater
.Parameters.Add("@ReturnValue", SqlDbType.Int).Direction =
ParameterDirection.Output
Try
Dim SP_Result As Integer =
CInt(STR_SQLCOMMAND.ExecuteScalar())
'read the results
Select Case SP_Result
Case 0
'0 = Logon failed - unknown operator name and
password
Case 1
' 1 = logon was a sucscess
Case 2
' 2 = logon failed - User already logged on and is
not a master
Case 3
' 3 = logon failed - User password expired
Case Else
' 4 = Unable to Mark Operator as logged on
End Select
Catch Err As SqlClient.SqlException
Dim errorMessages As String
Dim Counter As Integer
For Counter = 0 To Err.Errors.Count - 1
errorMessages += "Message " &
Err.Errors(Counter).Message & ControlChars.NewLine
Next
Console.WriteLine(errorMessages)
End Try
End With
I have checked the parameter values and ther correct . SP_Result always
returns a 0 .. now i have tried in a query editior to ececute the stored
proc with the same input parms and got a 1 result which is correct
declare @rtn int
exec bossdata.dbo.OperatorLogon 'MyName', 'MyPassword', '999', @ReturnValue
= @rtn output
print @rtn ( @rtn = 1 )
is there any hope at getting this to work, or should i just pack it all in
and give up. I know for certin the info being parmed in should return a 1
from the Stored Proc as a 1 result updates a table which is being done, so im
assuming it the way im reading the returned value ?
running vb.net (2003) and SQL 2005.. the story thus far is with a lot of
help and a prevailing wind i have come up with the following
( CON_BOSSCONNECTION is already connected )
Dim InputString() As String
Dim ReturnValue As Integer
InputString = Split(InputParm, ";")
' set the query commands
STR_SQLCOMMAND.CommandText = "BossData.dbo.OperatorLogon"
STR_SQLCOMMAND.CommandType = CommandType.StoredProcedure
STR_SQLCOMMAND.CommandTimeout = 30
With STR_SQLCOMMAND
' set the query commands
.CommandText = "BossData.dbo.OperatorLogon"
.CommandType = CommandType.StoredProcedure
.CommandTimeout = 30
' set the connection
.Connection = CON_BOSSCONNECTION
' Set the 1st Parameter
.Parameters.Add("@OperatorName", SqlDbType.VarChar, 20).Value =
InputString(0).ToString
' Set the 2nd Parameter
.Parameters.Add("@OperatorPassword", SqlDbType.VarChar,
20).Value = InputString(1).ToString
' Set the 3rd Parameter
.Parameters.Add("@PasswordLife", SqlDbType.VarChar, 3).Value =
InputString(2).ToString
' Set the returned Paramater
.Parameters.Add("@ReturnValue", SqlDbType.Int).Direction =
ParameterDirection.Output
Try
Dim SP_Result As Integer =
CInt(STR_SQLCOMMAND.ExecuteScalar())
'read the results
Select Case SP_Result
Case 0
'0 = Logon failed - unknown operator name and
password
Case 1
' 1 = logon was a sucscess
Case 2
' 2 = logon failed - User already logged on and is
not a master
Case 3
' 3 = logon failed - User password expired
Case Else
' 4 = Unable to Mark Operator as logged on
End Select
Catch Err As SqlClient.SqlException
Dim errorMessages As String
Dim Counter As Integer
For Counter = 0 To Err.Errors.Count - 1
errorMessages += "Message " &
Err.Errors(Counter).Message & ControlChars.NewLine
Next
Console.WriteLine(errorMessages)
End Try
End With
I have checked the parameter values and ther correct . SP_Result always
returns a 0 .. now i have tried in a query editior to ececute the stored
proc with the same input parms and got a 1 result which is correct
declare @rtn int
exec bossdata.dbo.OperatorLogon 'MyName', 'MyPassword', '999', @ReturnValue
= @rtn output
print @rtn ( @rtn = 1 )
is there any hope at getting this to work, or should i just pack it all in
and give up. I know for certin the info being parmed in should return a 1
from the Stored Proc as a 1 result updates a table which is being done, so im
assuming it the way im reading the returned value ?