0

我想在我的 Combobox 中显示我的查询结果,但我收到一个错误“无效参数或未传递参数”。任何意见是极大的赞赏。这是我的代码。

Private Sub frmAdvancePayment_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    lstBillNum.Items.Clear()
    txtLName.Text = frmAmortizationFee.txtLName.Text
    txtFName.Text = frmAmortizationFee.txtFName.Text
    lblMaAmount.Text = frmAmortizationFee.txtAmort.Text
    lblAcctNum.Text = frmAmortizationFee.cmbAccountNo.Text


    Dim connection_string As String = "Data Source=.\sqlexpress;Initial Catalog=CreditAndCollection;Integrated Security=True"

    Dim Connection As New SqlConnection(connection_string)
    Dim da As New SqlDataAdapter
    Dim command As New SqlCommand
    command.Connection = Connection

    command.CommandText = "showBillingNum"
    command.CommandType = CommandType.StoredProcedure
    command.Parameters.AddWithValue("@AcctNum", lblAcctNum.Text)

    Connection.Open()

    da.SelectCommand = command
    Dim dt As New DataSet
    da.Fill(dt)

    cmbBillNum.DataSource = dt

    cmbBillNum.DisplayMember = "BillNum"
    cmbBillNum.ValueMember = "BillNum"
    command.ExecuteNonQuery()
    Connection.Close()

End Sub
4

1 回答 1

0

我猜它正在工作,但你仍然收到错误?这是因为倒数第三行:

command.ExecuteNonQuery()

在已经运行后执行查询。不知道为什么会产生那个错误,但我知道那行是错误的。

于 2013-09-23T20:13:53.710 回答