开发者

help date format in vb.net

开发者 https://www.devze.com 2023-01-01 17:40 出处:网络
Dim Con As OleDb.OleDbConnection Dim Sql As String = Nothing Dim Reader As OleDb.OleDbDataReader Dim ComboRow As Integer = -1
     Dim Con As OleDb.OleDbConnection
    Dim Sql As String = Nothing
    Dim Reader As OleDb.OleDbDataReader
    Dim ComboRow As Integer = -1
    Dim Columns As Integer = 0
    Dim Category As String = Nothing
    Dim oDatumMin As Date
    Dim column As String
    column = Replace(TxtDateMax.Text, "'", "''")
    'oDatumMin = Convert.ToDateTime(TxtDateMin.Text)

    oDatumMin = DtpMin.Value
    Dim oPath As String
    oPath = Application.StartupPath

    ' Select records.
    Con = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & oPath & "\trb.accdb;")
    Dim cmd As New OleDb.OleDbCommand
    'Dim data_reader As OleDbDataReader = cmd.ExecuteReader()
    Sql = ("SELECT * FROM " & cmbvalue & " WHERE Datum>='" & oDatumMin & "'")
    cmd = New OleDb.OleDbCommand(Sql, Con)
    Con.Open()
    Reader = cmd.ExecuteReader()
    Do While Reader.Read()
        Dim new_item As New ListViewItem(Reader.Item("Datum").ToString)
        new_item.SubItems.Add(Reader.Item("Steleks i krpe za cišcenje-toal papir-ubrusi-domestos").T开发者_如何学运维oString)
        new_item.SubItems.Add(Reader.Item("TEKUCINA ZA CIŠCENJE PLOCICA").ToString)
        new_item.SubItems.Add(Reader.Item("KESE ZA SMECE").ToString)
        new_item.SubItems.Add(Reader.Item("OSTALO-džoger-spužva za laminat").ToString)
        new_item.SubItems.Add(Reader.Item("PAPIR").ToString)
        LvIzvjestaj.Items.Add(new_item)

    Loop

    ' Close the connection.strong text
    Con.Close()``

when i select table,(cmbvalue) from combobox and when i select date from datetime picker (dtp) or in last case from texbox converted to date and time sql looks like this "SELECT * FROM Uprava WHERE Datum>='2.6.2010 10:28:14'" and all query looks ok but am geting

Data type mismatch in criteria expression. error for date (oDatumMin) when excute column in access is also set to date i have no idea what else to try


I suspect this is a localisation issue. Try changing the date format to one which should be universally recognised:

SELECT * FROM Uprava WHERE Datum >='2010/06/02 10:28:14'

[What is your server locale/code page?]


Dim sql As String = "SELECT * FROM MyTable WHERE Datum >= ?"
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql)
cmd.Parameters.Add(New OleDb.OleDbParameter("@Datum", OleDb.OleDbType.Date))
cmd.Parameters("Datum").Value = oDatumMin

http://msdn.microsoft.com/de-de/library/bbw6zyha.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号