By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Updating Access Datetime field using OleDBDataAdapter

P: n/a
RML
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

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"RML" <RM*@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
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

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.