VB.Net and MS Access problem
-
I am trying to use VB.Net as a front end for a MS Access database. I am trying to get the date/time into a format I want to use(displaying, modifying etc). I have the field in Access defined as date/time. I only want to use the time portion in 24hr format. My format is HH:nn:ss and the input mask reflects this. When I display one record in VB.Net, the date is the only thing that is showing and instead of showing today's date, it is showing a date from 30 Dec 1899. The data I already have stored in the Access database for that field is 23:55:00. What do I need to do in order to get it to work the way I would like?
-
I am trying to use VB.Net as a front end for a MS Access database. I am trying to get the date/time into a format I want to use(displaying, modifying etc). I have the field in Access defined as date/time. I only want to use the time portion in 24hr format. My format is HH:nn:ss and the input mask reflects this. When I display one record in VB.Net, the date is the only thing that is showing and instead of showing today's date, it is showing a date from 30 Dec 1899. The data I already have stored in the Access database for that field is 23:55:00. What do I need to do in order to get it to work the way I would like?
You are displaying the date in the text box in the wrong format. You can reformat the date in a textbox like this: Dim MyDate As DateTime = Me.TextBox1.Text Me.TextBox1.Text = MyDate.ToLongTimeString() How did you setup the Dataset, etc? (Wizard or code) There is probably a better way of doing it if you could explain. Green2Go
-
You are displaying the date in the text box in the wrong format. You can reformat the date in a textbox like this: Dim MyDate As DateTime = Me.TextBox1.Text Me.TextBox1.Text = MyDate.ToLongTimeString() How did you setup the Dataset, etc? (Wizard or code) There is probably a better way of doing it if you could explain. Green2Go
I set up the dataset through a wizard. The only thing I have coded an event on closing to update the database. Public Class frmSingle Private Sub DataBindingNavigatorSaveItem_Click(ByVal _ sender As System.Object, ByVal e As System.EventArgs) _ Handles DataBindingNavigatorSaveItem.Click Me.Validate() Me.DataBindingSource.EndEdit() Me.DataTableAdapter.Update _(Me.TandemsheetsDataSet.data) End Sub Private Sub frmSingle_FormClosing(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosingEventArgs) _ Handles Me.FormClosing Me.DataTableAdapter.Update _(Me.TandemsheetsDataSet.data) End Sub Private Sub frmSingle_Load(ByVal sender As _ System.Object, ByVal e As System.EventArgs) Handles _ MyBase.Load 'TODO: This line of code loads data into 'the 'TandemsheetsDataSet.data' table. You can 'move, or remove it, as needed. Me.DataTableAdapter.Fill _ (Me.TandemsheetsDataSet.data) End Sub End Class
-
I am trying to use VB.Net as a front end for a MS Access database. I am trying to get the date/time into a format I want to use(displaying, modifying etc). I have the field in Access defined as date/time. I only want to use the time portion in 24hr format. My format is HH:nn:ss and the input mask reflects this. When I display one record in VB.Net, the date is the only thing that is showing and instead of showing today's date, it is showing a date from 30 Dec 1899. The data I already have stored in the Access database for that field is 23:55:00. What do I need to do in order to get it to work the way I would like?
-
Does your format really have "nn", or is that just a typo?
Tom Garth Developer R. L. Nelson and Associates, Inc., Virginia
It was "nn" because that is what Access used as the minute placeholder in the custom format. Access probably uses it to distinguish from the month for which it uses mm. At least it is working that way. I think I might have found what I am looking for though. In VB on the properties for the textbox I am using, I changed the Format property to Custom and changed the CustomFormat property to HH:mm:ss. It works the way I want it to now. Thanks to Tom and green2go for attempting to help me. :)