0

我正在尝试使用 vb2008 在我的 sqlce 数据库中插入一条记录,但我收到一条消息- A parameter is missing (parameter ordinal=1) ,我认为这意味着第一个变量- @dt_id无效或未被接受。这是怎么回事。如果不是,是什么导致了该消息?

这是代码:

con = New SqlCeConnection(connectionString)
    con.Open()

    Try
        cmd = New SqlCeCommand("Insert into [daily_detail] ([dd_id], [dd_customers], [dd_pennies], [dd_nickels], [dd_dimes], [dd_quarters], [dd_singles], [dd_fives], [dd_tens], [dd_twenties], [dd_fifties], [dd_hundreds], [dd_salestax], [dd_tips], [dd_charged], [dd_gross], [dd_net], [dd_new_drawer]) values(@dt_id, @customers, @pennies, @nickels, @dimes, @quarters, @dollars, @fives, @tens, @twenties, @fifties, @hundreds, @salestax, @tips, @charged, @gross, @net, @new_drawer)", con)


        cmd.executeNonQuery()
        cmd.Parameters.Addwithvalues("@dt_id", current_date)
        cmd.parameters.Addwithvalues("@customers", w_customers)
        cmd.parameters.Addwithvalues("@pennies", w_pennies)
        cmd.parameters.Addwithvalues("@nickels", w_nickels)
        cmd.parameters.Addwithvalues("@dimes", w_dimes)
        cmd.parameters.Addwithvalues("@quarters", w_quarters)
        cmd.parameters.Addwithvalues("@dollars", w_dollars)
        cmd.parameters.Addwithvalues("@fives", w_fives)
        cmd.parameters.Addwithvalues("@tens", w_tens)
        cmd.parameters.Addwithvalues("@twenties", w_twenties)
        cmd.parameters.Addwithvalues("@fifties", w_fifties)
        cmd.parameters.Addwithvalues("@hundreds", w_hundreds)
        cmd.parameters.Addwithvalues("@salestax", w_salestax)
        cmd.parameters.Addwithvalues("@tips", w_tips)
        cmd.parameters.Addwithvalues("@charged", w_charged)
        cmd.parameters.Addwithvalues("@gross", w_gross)
        cmd.parameters.Addwithvalues("@net", w_net)
        cmd.parameters.Addwithvalues("@new_drawer", w_new_drawer)

    Catch ex As Exception
        msg_text = "Insert failed: " + ex.Message
        MsgBox(msg_text, , msgtitle)
        Exit Sub
    End Try
4

0 回答 0