input time but view date ?

sulistyanto

Member
Joined
Jun 19, 2006
Messages
8
Programming Experience
Beginner
i set in MS Access database the format is short time & in form too,i use masked text box but when i want view in form vb.net,it's show "12/30/1899".Anyone can help me?
 
i'm not insert any data in MS Access but from microsoft book(about VB.Net in Access programming),"12/30/1899" is value from OLEDBType.But the book didn't give solve the problem :(
 
the code

at input form
public sub new()
mybase.new()
initializationcomponent()
oledbconnection1.open()
end sub

private sub button1_click(byval sender as system.object,byval e as system.eventargs)handles button1.click
dim sql as string
sql="insert into work(hour)values('"& maskedtextbox1.text &"')"
oledbdataadapter1.insertcommand.commandtext=sql
oledbdataadapter1.insertcommand.executenonquery()
end sub

at view form
private sub view_click(byval sender as system.object,byval e as system.eventargs)handles view.click
dim sql as string
sql="select hour from work"
oledbdataadapter1.selectcommand.commandtext=sql
dataset1.clear()
oledbdataadapter1.fill(dataset1,"work")
datagrid1.setdatabinding(dataset1,"work")
end sub
 
Ok, I am trying to simulate your problems, I think you need these code in your form load event:


Dim dgTableStyle As DataGridTableStyle
dgTableStyle =
New DataGridTableStyle
dgTableStyle.MappingName =
"work"
' Set other properties.
dgTableStyle.AlternatingBackColor = Color.LightGray
dgTableStyle.AllowSorting =
True
Dim TextCol As DataGridTextBoxColumn
TextCol =
New DataGridTextBoxColumn
TextCol.MappingName =
"hour"
TextCol.HeaderText = "hour"
TextCol.Width = 100
TextCol.Format =
"HH:mm"
dgTableStyle.GridColumnStyles.Add(TextCol)
Me.DataGrid1.TableStyles.Add(dgTableStyle)
 
thank you :)

thanks for your answer.I follow your suggestion and it work :)
the source code that you give to me really help me :D


THANKS FOR LINGSN, you really :cool:
 
Back
Top