Hi im trying to insert date to my .mdb database, but when i check it, the date turned into random numbers, like 3.2938482

here's my code

Dim constring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dbperpus.mdb"
        Dim query2 As String = "select * from fpinjam2"
        connect = New OleDbConnection(constring)

        connect.Open()
        cmd = New OleDbCommand(query2, connect)
        datar = cmd.ExecuteReader
        datar.Read()

        Dim insert As String = "insert into fpinjam2 values('" & nimtxt.Text & " ','" & namatxt.Text & "','" & kodetxt.Text & "','" & judultxt.Text & "','" & tanggalpinjam.Text & "'," & tanggalbaliktxt.Text & ")"
        cmd = New OleDbCommand(insert, connect)
        cmd.ExecuteNonQuery()
        MessageBox.Show("insert successful")
        connect.Close()
        datas.Clear()
        mainconnect()

    End Sub

image: http://i.imgur.com/yfdyO.png

thanks :)

See this "tanggalpinjam.Text and tanggalbaliktxt.Text"
I think this the problem. You want to insert a date of borrowed date n returning date but you insert it as text.
Just convert it to date format. Make sure the type of both column is date in your database not text or numeric.

i changed the type of both column into "date and time" , and this happen :(
http://i.imgur.com/XmUrZ.png

did you already convert it to date format?

FormatDateTime(tanggalbaliktxt.Text, DateFormat.ShortDate)

its like this right?

Dim insert As String = "insert into fpinjam2 values('" & nimtxt.Text & " ','" & namatxt.Text & "','" & kodetxt.Text & "','" & judultxt.Text & "','" & FormatDateTime(tanggalpinjam.Text, DateFormat.ShortDate) & "'," & FormatDateTime(tanggalbaliktxt.Text, DateFormat.ShortDate) & ")"

still not working

ahh..its solved now, its should be like this

Dim insert As String = "insert into fpinjam2 values('" & nimtxt.Text & " ','" & namatxt.Text & "','" & kodetxt.Text & "','" & judultxt.Text & "','" & tanggalpinjam.Text & "','" & tanggalbaliktxt.Text & "')"

instead of

Dim insert As String = "insert into fpinjam2 values('" & nimtxt.Text & " ','" & namatxt.Text & "','" & kodetxt.Text & "','" & judultxt.Text & "','" & tanggalpinjam.Text & "'," & tanggalbaliktxt.Text & ")"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.