Question error on insert data to database

ssaa

New member
Joined
Jul 25, 2011
Messages
4
Programming Experience
Beginner
Too many arguments to 'Public Overridable Overloads Function Insert(itemname As String, Supplier As String, Manufacturer As String, Category As String, Instock As System.Nullable(Of Integer)) As Integer'. how to solve this error, here instock is the interger type.please iam waiting for the reply.
 
If the error message says "Too many arguments" then you are passing too many arguments. The solution is to not pass too many arguments. The method has five parameters so you need to pass five arguments.
 
Here is the code.The database connecition did through the Designer .

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

viewitems.Additems_tableTableAdapter.Insert(Me.itemcode.Text, Me.itemname.Text, _
Me.supplier.Text, Me.manufacturer.Text, _
Me.category.Text, Me.instock.Text)
MsgBox("SAVED")
End Sub
 
OK, I understand that you don't have much programming experience but I'm fairly sure that you have plenty of counting experience. The error message told you exactly what the issue was, I told you exactly what the issue was and you insisted that you were passing the correct number of arguments, but your code demonstrates that you are not. The method you are calling has five (5) parameters:

itemname
Supplier
Manufacturer
Category
Instock

You are calling it with six (6) arguments:

Me.itemcode.Text
Me.itemname.Text
Me.supplier.Text
Me.manufacturer.Text
Me.category.Text
Me.instock.Text

Six (6) does not equal five (5), therefore you are, as the error message and I have already told you, calling the method with too many arguments. If you want to pass the item code as well then you need to change the method, which you would have to do in the DataSet designer.
 
Back
Top