G
Guest
Hi,
I'm attempting to run a SQL SP from ASP.NET 1.1 using the
EnterpriseLibrary. I have successfully creted a connection and am
attempting to call the ExecuteScalar method. The problem is that my SP
is always returning a value of zero when it should (under the right
conditions) return a one. When called from the QA or EM the SP does
return the correct results, it's just from the code it doesn't.
Here's my VB:
<Start Code>
Public Function Login(ByVal strUserName As String, _
ByVal strPassword As String) As Integer
Dim nID As Integer = 1
Dim sqlCommand As String
Dim dbCommandWrapper As DBCommandWrapper
sqlCommand = "procUserValidate"
dbCommandWrapper =
db.GetStoredProcCommandWrapper(sqlCommand)
Call dbCommandWrapper.AddInParameter("@vchUser",
DbType.String, strUserName)
Call dbCommandWrapper.AddInParameter("@vchPword",
DbType.String, strPassword)
Call dbCommandWrapper.AddOutParameter("@bValid",
DbType.Int16, 1)
Try
nID = CType(db.ExecuteScalar(dbCommandWrapper),
Integer)
Catch e As Exception
Throw e
End Try
Return nID
End Function
</End Code>
.... and here's the SP it's calling...
<Start SQL>
CREATE PROCEDURE procUserValidate
@vchUser typUserUsername,
@vchPword typUserPassword,
@bValid BIT OUTPUT
AS
IF EXISTS(
SELECT GUID
FROM dbo.tblUsers (NOLOCK)
WHERE Username = @vchUser
AND [Password] = @vchPword
)
SET @bValid = 1
ELSE
SET @bValid = 0
</End SQL>
I think It's something to do with the DataTypes defined in the code,
but any pointers would be appreciated.
<M>
I'm attempting to run a SQL SP from ASP.NET 1.1 using the
EnterpriseLibrary. I have successfully creted a connection and am
attempting to call the ExecuteScalar method. The problem is that my SP
is always returning a value of zero when it should (under the right
conditions) return a one. When called from the QA or EM the SP does
return the correct results, it's just from the code it doesn't.
Here's my VB:
<Start Code>
Public Function Login(ByVal strUserName As String, _
ByVal strPassword As String) As Integer
Dim nID As Integer = 1
Dim sqlCommand As String
Dim dbCommandWrapper As DBCommandWrapper
sqlCommand = "procUserValidate"
dbCommandWrapper =
db.GetStoredProcCommandWrapper(sqlCommand)
Call dbCommandWrapper.AddInParameter("@vchUser",
DbType.String, strUserName)
Call dbCommandWrapper.AddInParameter("@vchPword",
DbType.String, strPassword)
Call dbCommandWrapper.AddOutParameter("@bValid",
DbType.Int16, 1)
Try
nID = CType(db.ExecuteScalar(dbCommandWrapper),
Integer)
Catch e As Exception
Throw e
End Try
Return nID
End Function
</End Code>
.... and here's the SP it's calling...
<Start SQL>
CREATE PROCEDURE procUserValidate
@vchUser typUserUsername,
@vchPword typUserPassword,
@bValid BIT OUTPUT
AS
IF EXISTS(
SELECT GUID
FROM dbo.tblUsers (NOLOCK)
WHERE Username = @vchUser
AND [Password] = @vchPword
)
SET @bValid = 1
ELSE
SET @bValid = 0
</End SQL>
I think It's something to do with the DataTypes defined in the code,
but any pointers would be appreciated.
<M>