I'm passing 2 params to a Stored Procedure bla bla bla.
I know the SP works as I can call it in a sql editor using
exec sp_isintrastate2 37923, 38544
It returns a correct value at every time.
The params are populating correctly. I can view them with a watch
When I call the sp in the code below I get a -1 back.
I can't seem to find what I goofed on. Can I get another set of eyes on this code HA.
Thanks
I know the SP works as I can call it in a sql editor using
exec sp_isintrastate2 37923, 38544
It returns a correct value at every time.
The params are populating correctly. I can view them with a watch
When I call the sp in the code below I get a -1 back.
I can't seem to find what I goofed on. Can I get another set of eyes on this code HA.
Thanks
Code:
Public Shared Function ckintrastate(ByVal fzip As String, ByVal tzip As String) As Int32
Dim isintra As Int32 = 5
Dim sqlconn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings("fmsconn"))
Dim zipfrom As New SqlParameter
Dim zipto As New SqlParameter
Dim cmdintra As New SqlCommand
With cmdintra
.CommandText = ("sp_isintrastate2")
.Connection = sqlconn
.CommandType = CommandType.StoredProcedure
End With
With zipfrom
.Direction = ParameterDirection.Input
.DbType = DbType.Int32
.Value = fzip
.ParameterName = ("zipfrom")
End With
With zipto
.Direction = ParameterDirection.Input
.DbType = DbType.Int32
.Value = tzip
.ParameterName = ("zipto")
End With
cmdintra.Parameters.Add(zipfrom)
cmdintra.Parameters.Add(zipto)
sqlconn.Open()
Try
isintra = cmdintra.ExecuteNonQuery
Catch ex As System.Exception
sqlconn.Close()
End Try
If sqlconn.State = ConnectionState.Open Then
sqlconn.Close()
End If
Return isintra
End Function