DateTime Type in DataGrid...

johansenng

Newcomer
Joined
Jun 23, 2003
Messages
12
Hi, i am new to vb.net,, so pardon my ignorance..

I have query a datetime type (containing a Time value) using SQL select into a dataset and then to a datagrid. However when the program is exec, the column gives me the date value (which i did not enter.. should be the default date value), instead of the time value. How do i make the datagrid show only the Time value?? Thanks..

da.SelectCommand.CommandText = "SELECT [Today].Nric, [Personnel].Name," & _
"[Today].TimeIn, [Today].TimeOut, [Personnel].MobileNo, [Personnel].Genre " & _
"FROM [Today] inner join [Personnel] on" & _
"[Today].Nric=[Personnel].Nric"
da.SelectCommand.CommandType = CommandType.Text
Try
da.SelectCommand.ExecuteNonQuery()

Catch err As OleDbException
MessageBox.Show(err.ToString)
End Try

ds.Clear()
da.Fill(ds, "today")
objConnection.Close()

dg.DataSource = ds
dg.DataMember = "today"
:confused:
 
When it comes to saving Time in a table I prefer to use varchar (or text based data types).
If you're concerned with calculations between TimeIn and TimeOut you can Convert or Cast the values when needed.
 
ok..

Hi, thanks for replying..

so what you mean is to input it as a text.. but when i need to use it, i covert it to time type using convert..

ok.. i get it.. thanks..
 
Back
Top