We help IT Professionals succeed at work.
Get Started

Visual Basic 2010: Read / Write Dates to Access Database

cspdmg asked
Last Modified: 2012-05-12
I am using a VB2010 form as a front end to an Access database. I am having two problems when reading/writing date fields.

1) When reading a date from the dataset, it doesn't display properly on the form if the date has a single digit for the month and/or day. Example: 9/23/2011 displays as 92/32/011

I'm using the following to read into a masked text box with the mask set to short date:

mtxtRequestDate.Text = ds.Tables("WorkOrders").Rows(inc).Item("RequestDate").ToString

2)When saving a date field, if the field is blank I get the following error:

String was not recognized as a valid DateTime.Couldn't store <  /  /> in RequestDate Column.  Expected type is DateTime.

I'm using the following to write to the dataset:

ds.Tables("WorkOrders").Rows(inc).Item("RequestDate") = mtxtRequestDate.Text

Thanks in advance.

Watch Question
Senior .Net Consultant
Top Expert 2016
This problem has been solved!
Unlock 2 Answers and 15 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE