 |
|
| .NET DotNet Forum Index » ADO .NET Forum » Query with datetime field...... |
|
Page 1 of 1 |
|
| Author |
Message |
| Blue Skys... |
Posted: Fri Oct 02, 2009 9:47 am |
|
|
|
Guest
|
Hi, folks!
This is a simple questions (hopefully with a simple answer).
I need to include the fractional seconds from a DateTime field from an
MS-SQL server when I run a query. Currently, ADO.NET does not return the
fractional seconds into VB.NET (or C# for that matter) in the sample code
included below.
How can I get the fractional seconds included in the myTime string?
TIA...
'***SAMPLE CODE***
sqlDataSource.ConnectionString = "Provider=SQLOLEDB.1;driver=SQL
Server;server=localhost;uid=user;pwd=pwd;"
sqlStmt = "SELECT ID, aDateTimeField, Blah,... FROM myTable"
sqlDataSource.SelectCommand = sqlStmt
sqlDataSource.SelectCommandType = SqlDataSourceCommandType.Text
Try
DataView = sqlArticle.Select(DataSourceSelectArguments.Empty)
DataTable = DataView.ToTable()
myTime = DataTable.Rows(0).Item("aDateTimeField")
Catch err As Exception
...
Finally
DataTable.Dispose()
DataView.Dispose()
End Try |
|
|
| Back to top |
|
|
|
| Scott M.... |
Posted: Fri Oct 02, 2009 12:53 pm |
|
|
|
Guest
|
"Blue Skys" <blueskys at (no spam) msn.com> wrote in message
news:lMOdnem0Ic98glvXnZ2dnUVZ_gGdnZ2d at (no spam) giganews.com...
Quote: Hi, folks!
This is a simple questions (hopefully with a simple answer).
I need to include the fractional seconds from a DateTime field from an
MS-SQL server when I run a query. Currently, ADO.NET does not return the
fractional seconds into VB.NET (or C# for that matter) in the sample code
included below.
How can I get the fractional seconds included in the myTime string?
TIA...
'***SAMPLE CODE***
sqlDataSource.ConnectionString = "Provider=SQLOLEDB.1;driver=SQL
Server;server=localhost;uid=user;pwd=pwd;"
sqlStmt = "SELECT ID, aDateTimeField, Blah,... FROM myTable"
sqlDataSource.SelectCommand = sqlStmt
sqlDataSource.SelectCommandType = SqlDataSourceCommandType.Text
Try
DataView = sqlArticle.Select(DataSourceSelectArguments.Empty)
DataTable = DataView.ToTable()
myTime = DataTable.Rows(0).Item("aDateTimeField")
Catch err As Exception
...
Finally
DataTable.Dispose()
DataView.Dispose()
End Try
I don't see your variable declaration for myTime. Also, when you are
getting the value from the DataTable, is the column "aDateTimeField" defined
as a DateTime type? If so, you should be casting it to that type upon
retrieval because the Item property of a DataTable row only returns an
Object.
-Scott |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Wed Dec 09, 2009 11:42 pm
|
|