Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to get time as time not date...

Status
Not open for further replies.

jeffmoore

Programmer
Aug 29, 2003
301
0
0
US
need to get time as time not date...

Dim MyConnection As System.Data.Odbc.OdbcConnection
Dim MyDataTable As New DataTable
Dim MyDataAdaptor As System.Data.Odbc.OdbcDataAdapter
Dim strMyConnection, strSavedFolder, strFilename As String
strSavedFolder = "c:\inetpub\ strFilename = "test.csv"
strMyConnection = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & strSavedFolder & ";"
MyConnection = New Odbc.OdbcConnection(strMyConnection)
MyDataAdaptor = New System.data.Odbc.OdbcDataAdapter("select * from [" + strFilename + "]", MyConnection)
MyDataAdaptor.Fill(MyDataTable)
DataGrid1.DataSource = MyDataTable

okay the code works great ... except for on little prob.
one of my fields is a time field. It's showing up on the datagrid as a date...
How do I set the conversion processes.
In access I would use an Import Spec to define my fields. How is this done in vb?
tia
jeff
 
Add a string column and set the values of this column cells to the time string of the date value.
 
that was all greek to me ..... i'm a struggling newbie
;)
 
Here is what I have:

Dim connect As New SqlConnection("initial catalog=rathmisc;data source=server;user id=sysadm;password=sysadm")
Dim MyDataAdaptor As New System.Data.sqlclient.SqlDataAdapter("select * from tbl_data_laser_1", connect)
Try
connect.Open()
Dim DataSet As New DataTable
MyDataAdaptor.Fill(DataSet)
DataGrid1.DataSource = DataSet

Catch Ex As Exception
Console.WriteLine("error: " & Ex.Message)
End Try

connect.Close()


If you can explain what you said above in context of my code that would be real helpfull.


tia jeff
 
change your SQL to pull back the fields individually, then format the one how ever you want it.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
okay but how do i put them into the dataset individualy??
 
Code:
MyDataAdaptor = New System.data.Odbc.OdbcDataAdapter("select Field1, Field2, Field3, SELECT CONVERT(varchar(8), Field4, 8) from [" + strFilename + "]", MyConnection)

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top