Monday, February 20, 2012

problem useing Stored Procedure form vb.net

i have created a stored prcedure but is always give error : and please check the ways is correct using stored procedure

"Procedure or Function 'Add_Cb_Entry' expects parameter '@.Date', which was not supplied."

Dim SqlPrm As SqlParameter

Dim SqlCmd As New SqlCommand

With SqlCmd

.Connection = SqlConnection 'this is my connection setting

.CommandText = "Dbo.Add_Cb_Entry"

.CommandType = CommandType.StoredProcedure

End With

SqlPrm = SqlCmd.Parameters.Add("@.Cashbook_Id", Nothing)

SqlPrm.Direction = ParameterDirection.Output

SqlPrm = SqlCmd.Parameters.Add("@.Date", SqlDbType.DateTime, 8, TxtDate.Text)

SqlPrm.Direction = ParameterDirection.Input

SqlPrm = SqlCmd.Parameters.Add("@.Entry_ID", SqlDbType.Int, 4, "4")

SqlPrm = SqlCmd.Parameters.Add("@.Entry_Name", SqlDbType.VarChar, 75, "Irfan Imdad Memon")

SqlPrm = SqlCmd.Parameters.Add("@.Description", SqlDbType.VarChar, 100, "Chk")

SqlPrm = SqlCmd.Parameters.Add("@.Amount", SqlDbType.Money, 13, "1000.20")

SqlPrm = SqlCmd.Parameters.Add("@.Type", SqlDbType.NChar, 2, "DB")

SqlPrm = SqlCmd.Parameters.Add("@.Entry_Status", SqlDbType.VarChar, 20, "Account")

SqlPrm = SqlCmd.Parameters.Add("@.Ref_No", SqlDbType.Int, 4, "1")

SqlPrm = SqlCmd.Parameters.Add("@.Ref_Status", SqlDbType.VarChar, 20, "MeterialPurchase")

OpenConnection() 'this is my connection setting

SqlCmd.ExecuteNonQuery()

CloseConnection() 'this is my connection setting

TxtInvoiceNo.Text = SqlCmd.Parameters("@.Cashbook_Id").Value

hi
when you use this statement:

SqlPrm = SqlCmd.Parameters.Add("@.Cashbook_Id", Nothing)

sql server not found Nothing !
you set this parameter with zero or any varchar.

good luck

No comments:

Post a Comment