Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
VB
Public Shared Function CreateNewAMSPOSEntry(ByVal objAMSPOSEntry As clsAMSPOSEntry) As Integer

            If objAMSPOSEntry Is Nothing Then
                Throw New ArgumentNullException("objAMSPOSEntry")
            End If

            Dim db As DBAccess = New DBAccess
            Dim sqlCmd As SqlCommand = New SqlCommand()

            db.AddParamToSQLCmd(sqlCmd, "@SERIAL_NO", SqlDbType.NVarChar, 30, ParameterDirection.Input, objAMSPOSEntry.SERIAL_NO)
            db.AddParamToSQLCmd(sqlCmd, "@FLG_TYPE", SqlDbType.Bit, 1, ParameterDirection.Input, objAMSPOSEntry.FLG_TYPE)
            db.AddParamToSQLCmd(sqlCmd, "@SLNO", System.Data.SqlDbType.Int, 8, ParameterDirection.Output,objAMSPOSEntry.SLNO)

            db.SetCommandType(sqlCmd, CommandType.StoredProcedure, "SP_CREATEPOSENTRY")
            db.ExecuteScalarCmd(sqlCmd)
            Return sqlCmd.Parameters("@@IDENTITY").Value
        End Function


Save code:
VB
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
       Dim ret As Boolean
       Dim flg As Boolean
       Dim objAMSPOSEntry As clsAMSPOSEntry = New clsAMSPOSEntry
       If txtSerialNum.Text <> "" Then
           objAMSPOSEntry.SERIAL_NO = txtSerialNum.Text
           If rdbAcc.Checked = True Then
               flg = True
           Else
               flg = False
           End If
           objAMSPOSEntry.FLG_TYPE = flg
           'If Not txtPONO.Text Is Nothing Then
           ret = clsAMSPOSEntry.CreateNewPOSEntry(objAMSPOSEntry)
           ' End If
           If ret = True Then
               MsgBox("Successfully Inserted Record!")
           End If
           Else
            MsgBox("Please fill the form before click on Save!")
        End If
    End Sub

Store Procedure:

ALTER PROCEDURE [dbo].[SP_CREATEPOSENTRY]
(
	
	@SERIAL_NO nvarchar(30),
	@FLG_TYPE bit,
	
)
AS
BEGIN
INSERT INTO [TBL_DEVMASTER] ([SERIAL_NO],  [FLG_TYPE]) VALUES ( @SERIAL_NO,  @FLG_TYPE);
	
RETURN @@IDENTITY
END;
Posted
Updated 17-Jun-13 22:42pm
v2

1 solution

Either change your Stored Procedure to include the @SLNO parameter, or don't try to pass it to SQL from your VB code:
VB
db.AddParamToSQLCmd(sqlCmd, "@SERIAL_NO", SqlDbType.NVarChar, 30, ParameterDirection.Input, objAMSPOSEntry.SERIAL_NO)
db.AddParamToSQLCmd(sqlCmd, "@FLG_TYPE", SqlDbType.Bit, 1, ParameterDirection.Input, objAMSPOSEntry.FLG_TYPE)
db.AddParamToSQLCmd(sqlCmd, "@SLNO", System.Data.SqlDbType.Int, 8, ParameterDirection.Output,objAMSPOSEntry.SLNO)

SQL
ALTER PROCEDURE [dbo].[SP_CREATEPOSENTRY]
(
	@SERIAL_NO nvarchar(30),
	@FLG_TYPE bit,
)
AS
The two must match!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900