I am new vb.net and I m working on project that will import excel file in datagrid. After import this file I need to save these file into SQL Server 2005 table. But I am receiving 'Procedure or function insertCashBook has too many arguments specified'.
Private Sub ButtonReconsilation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonReconsilation.Click
Dim connection As SqlConnection = database_connection()
connection.Open()
Dim count, I As Integer
I = 0
Try
Dim command As SqlCommand = New SqlCommand("insertCashBook", connection)
command.CommandType = CommandType.StoredProcedure
count = LoadCashBookDataSet.Tables(0).Rows.Count
While I < count
If NZ(LoadCashBookDataSet.Tables(0).Rows(I)(4)) = 0 Then
command.Parameters.AddWithValue("@DR", NZ(LoadCashBookDataSet.Tables(0).Rows(I)(4)))
command.Parameters.AddWithValue("@CR", Convert.ToDecimal(LoadCashBookDataSet.Tables(0).Rows(I)(5)))
ElseIf NZ(LoadCashBookDataSet.Tables(0).Rows(I)(5)) = 0 Then
command.Parameters.AddWithValue("@CR", NZ(LoadCashBookDataSet.Tables(0).Rows(I)(4)))
command.Parameters.AddWithValue("@DR", Convert.ToDecimal(LoadCashBookDataSet.Tables(0).Rows(I)(4)))
Else
command.Parameters.AddWithValue("@DR", Convert.ToDecimal(LoadCashBookDataSet.Tables(0).Rows(I)(4)))
command.Parameters.AddWithValue("@CR", Convert.ToDecimal(LoadCashBookDataSet.Tables(0).Rows(I)(5)))
End If
I = I + 1
End While
command.ExecuteNonQuery() 'Receive Error while execute this statement
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub