vb 2008:sqlce缺少参数参数ordinal = 1

时间:2013-09-11 18:29:05

标签: parameters sql-server-ce

我正在尝试使用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

0 个答案:

没有答案