Updating Access Datetime field using OleDBDataAdapter

G

Guest

Hi everyone,

I am using VB.NET 2003 and an OleDBDataAdapter to update an Access table's
DateTime field. The field's format is set to "General Date" (ie: 11/24/2004
8:00:00 AM). The problem is the field ends up with only a date, with no time
component.

In my project...
I added an OleDBDataAdapter using the wizzard to my form. I generated the
DataSet and added the desired table. I verified the field type in the
DataSet is "dateTime".

My code does this...
Me.dsTaskPro(0).CompletedOn = Now
Me.daTaskProcess.Update(Me.dsTaskPro)

The field ends up with today's date "11/24/2004", with no time component.

If I edit the field (using Access) with a date & time, say 11/24/2004
8:00:00 AM and then run my code I get a "Concurrency Violation" exception.

Amyone have any ideas?

Thanks RML
 
B

Bernie Yaeger

Hi RML,

The following code worked fine for me. Is it possible that your column is
not really a datetime column? Otherwise, I don't understand why you should
not be seeing the time. Are you displaying it in shortdatetime format?
strsqlselect = "select * from tblministryjoin order by todate"

Dim dam As OleDbDataAdapter

dam = New OleDbDataAdapter(strsqlselect, oconn)

Dim odsm As New DataSet("tblministryjoin")

dam.Fill(odsm, "tblministryjoin")

Dim commandbuilder_odsm As OleDbCommandBuilder = New
OleDbCommandBuilder(dam)

Dim irowm As DataRow

For Each irowm In odsm.Tables(0).Rows

irowm("fromdate") = Now

MessageBox.Show(Now)

MessageBox.Show(irowm("fromdate"))

Exit For

Next

Try

dam.Update(odsm, "tblministryjoin")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

HTH,

Bernie Yaeger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top