|
Posted by orandov@gmail.com on 11/03/71 11:37
Thank You for responding. I will try to explain further. I have a
function in VB.NET that gives the info of the parameters to the SP and
calls the SP.
Here is the function:
Public Function AddCheck(ByVal iEmployeeID As Integer, ByVal dNetIncome
As Decimal, ByVal dCheckDate As DateTime, ByVal iCheckNumber As
Integer) As Integer
Dim oSqlConnection As SqlConnection = GetConnection()
Dim oSqlCommand As SqlCommand
Dim oSqlParameter As SqlParameter
Dim iRetVal As Integer
oSqlCommand = New SqlCommand
oSqlCommand.Connection = oSqlConnection
oSqlCommand.CommandType = CommandType.StoredProcedure
oSqlCommand.CommandText = "spAddCheck"
oSqlParameter = New SqlParameter
oSqlParameter.ParameterName = "@EmployeeID"
oSqlParameter.SqlDbType = SqlDbType.Int
oSqlParameter.Value = iEmployeeID
oSqlCommand.Parameters.Add(oSqlParameter)
oSqlParameter = New SqlParameter
oSqlParameter.ParameterName = "@NetIncome"
oSqlParameter.SqlDbType = SqlDbType.Decimal
oSqlParameter.Value = dNetIncome
oSqlParameter.Scale = 4
oSqlParameter.Precision = 8
oSqlCommand.Parameters.Add(oSqlParameter)
oSqlParameter = New SqlParameter
oSqlParameter.ParameterName = "@CheckDate"
oSqlParameter.SqlDbType = SqlDbType.DateTime
oSqlParameter.Value = dCheckDate
oSqlCommand.Parameters.Add(oSqlParameter)
oSqlParameter = New SqlParameter
oSqlParameter.ParameterName = "@CheckNumber"
oSqlParameter.SqlDbType = SqlDbType.Int
oSqlParameter.Value = iCheckNumber
oSqlCommand.Parameters.Add(oSqlParameter)
oSqlParameter = New SqlParameter
oSqlParameter.ParameterName = "@CheckID"
oSqlParameter.SqlDbType = SqlDbType.Int
oSqlParameter.Direction = ParameterDirection.Output
oSqlCommand.Parameters.Add(oSqlParameter)
oSqlConnection.Open()
Try
oSqlCommand.ExecuteNonQuery()
Catch SqlExceptionErr As SqlException
End Try
oSqlConnection.Close()
Try
iRetVal = oSqlCommand.Parameters("@CheckID").Value
Catch Err As System.InvalidCastException
MessageBox.Show(Err.Message)
End Try
Return iRetVal
End Function
The parameter that gets truncated is the @NetIncome
Here is the SP:
CREATE PROCEDURE spAddCheck
@EmployeeID int,
@CheckDate datetime,
@NetIncome decimal,
@CheckNumber int,
@CheckID int output
AS
INSERT INTO
tblChecks
(
EmployeeID,
AmountPaid,
CheckDate,
CheckNumber
)
VALUES
(
@EmployeeID,
@NetIncome,
@CheckDate,
@CheckNumber
)
SET @CheckID = @@identity
GO
Thank You for your help,
Oran Levin
Navigation:
[Reply to this message]
|