如何使用vb更新当前日期时间?

时间:2016-06-18 19:30:36

标签: sql visual-studio-2015

我正在做更新记录,但我无法更新访问文件的时间

Issue_Daate数据类型是日期/时间,我设置的格式是一般日期

这是我的代码

[
    {
        "city": "City",
        "name": "Some Pharmacy",
        "zip": "778372",
        "mobile": "9880082229",
        "license_number": "SP22",
        "is_mobile_verified": false,
        "is_active": true,
        "created_on": "2016-06-18T19:01:02.901",
        "created_by": null,
        "email": "somepharmacy@gmail.com",
        "state": "State",
        "last_updated_by": null,
        "is_email_verified": false,
        "last_updated_on": "2016-06-18T19:01:02.901",
        "address_line_2": null,
        "id": "57659a6ea3b6561c0f20265e",
        "bank_account": {
            "bank_name": "HSBC",
            "account_type": "Savings",
            "account_number": "663822553"
        },
        "address_line_1": "Address"
    }
]

我有一个错误

Dim totalprice As Decimal = FormatCurrency(total_after_gst)
    Dim today As DateTime = System.DateTime.Now
    Dim status As String = "Completed"
    Dim sql1 As String = "Update [ordertbl] SET [Total_Price]=" & totalprice & ", [Issue_date]=" & today & ", [Status]='" & status & "' Where [ID] = " & code & " "
    Dim cmd1 As OleDbCommand = New OleDbCommand(sql1, conn)

    cmd1.Connection = conn
        cmd1.ExecuteScalar()

我不确定缺少哪个运算符=

1 个答案:

答案 0 :(得分:0)

在你的SQL字符串中只做一个

[Issue_date]=getdate()

[Issue_date]=getutcdate()

或者,如果您坚持在VB中执行此操作,那么首先在SQL服务器上执行select getdate(),因为VB和SQL的日期格式可能不同。然后根据SQL格式在VB中格式化日期,并将其放在单撇号之间。