错误:未为参数指定参数

时间:2014-02-07 19:25:40

标签: database vb.net windows ms-access-2007

我正在创建特定数据库问题的解决方案。我想在我的数据库中添加一个新产品,但我收到了这两个错误:

  

错误1未指定参数'PershkrimiProduktit'的'Public Overridable Overloads Function Insert(KodiProduktit As String,EmriProduktit As String,CmimiBlerjes As Decimal?,CmimiShitjes As Decimal?,SasiaProduktit As String,PershkrimiProduktit As String)As Integer' 。 C:\ Users \ Brilian \ Desktop \ POS \ GUI \ AddItem.vb 71 13 POS

     

错误2参数'SasiaProduktit'没有为'Public Overridable Overloads Function Insert指定参数'(KodiProduktit As String,EmriProduktit As String,CmimiBlerjes As Decimal?,CmimiShitjes As Decimal?,SasiaProduktit As String,PershkrimiProduktit As String)As Integer' 。 C:\ Users \ Brilian \ Desktop \ POS \ GUI \ AddItem.vb 71 13 POS

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' performojme verivikimin
        ' perform validation for barcode
        If TextBox1.Text.Trim = "" Then
            MsgBox("You should enter a barcode number", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox1.Focus()
            Exit Sub
        End If
        If Not IsNumeric(TextBox1.Text) Then
            MsgBox("The barcode number should include digits only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox1.Focus()
            Exit Sub
        End If
        If TextBox1.Text.Contains(".") Or TextBox1.Text.Contains("-") Then
            MsgBox("The barcode number should include digits only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox1.Focus()
            Exit Sub
        End If

        ' perform check for the item name
        If TextBox2.Text.Trim = "" Then
            MsgBox("You should enter name for the item", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox2.Focus()
            Exit Sub
        End If

        ' perform a check for the buy price
        If Not IsNumeric(TextBox3.Text) Then
            MsgBox("You should enter the buy price as a number", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox3.Focus()
            Exit Sub
        End If
        Dim ÇmimiBlerjes As Decimal = Decimal.Parse(TextBox3.Text)
        If ÇmimiBlerjes < 0 Then
            MsgBox("Buy price can't be negative", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox3.Focus()
            Exit Sub
        End If

        ' perform a check for the sell price
        If Not IsNumeric(TextBox4.Text) Then
            MsgBox("You should enter the sell price as a number", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox4.Focus()
            Exit Sub
        End If
        Dim ÇmimiShitjes As Decimal = Decimal.Parse(TextBox4.Text)
        If ÇmimiShitjes < 0 Then
            MsgBox("Sell price can't be negative", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox4.Focus()
            Exit Sub
        End If
        If ÇmimiShitjes <= ÇmimiBlerjes Then
            MsgBox("Sell price can't be less than buy price", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
            TextBox4.Focus()
            Exit Sub
        End If

        ' insert the item
        Try
            ' create the adapter
            Dim TA As New POSDSTableAdapters.ItemsTableAdapter

            ' insert the item
            TA.Insert(TextBox1.Text, TextBox2.Text, ÇmimiBlerjes, ÇmimiShitjes)

            ' close window and return ok
            Me.DialogResult = Windows.Forms.DialogResult.OK
        Catch ex As Exception

            ' display error message
            MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
        End Try
    End Sub
End Class

1 个答案:

答案 0 :(得分:0)

错误消息很明确。 Insert方法需要以下六个参数:

  • KodiProduktit As String
  • EmriProduktit As String
  • CmimiBlerjes As Decimal?
  • CmimiShitjes As Decimal?
  • SasiaProduktit As String
  • PershkrimiProduktit As String

但是,当你调用它时,你只传递了四个参数:

  • TextBox1.Text
  • TextBox2.Text
  • ÇmimiBlerjes
  • ÇmimiShitjes

您需要将另外两个参数传递给Insert方法,即SasiaProduktitPershkrimiProduktit(两个字符串)。如果您没有这些参数的值,则应该能够简单地传递Nothing,如下所示:

TA.Insert(TextBox1.Text, TextBox2.Text, ÇmimiBlerjes, ÇmimiShitjes, Nothing, Nothing)

或空字符串:

TA.Insert(TextBox1.Text, TextBox2.Text, ÇmimiBlerjes, ÇmimiShitjes, "", "")