ASA Programming Guide
Developing Applications with the .NET Data Provider
Accessing and manipulating data
The .NET Framework does not have a Time structure. If you want to fetch time values from Adaptive Server Anywhere, you must use the GetTimeSpan method. Using this method returns the data as a .NET Framework TimeSpan object.
For more information about the GetTimeSpan method, see GetTimeSpan method.
To convert a time value using the GetTimeSpan method
Declare and initialize a connection object.
AsaConnection conn = new AsaConnection( "Data Source=dsn-time-test;uid=dba;pwd=sql" );
Open the connection.
conn.Open();
Add a Command object to define and execute a SQL statement.
AsaCommand cmd = new AsaCommand( "SELECT id, time_col FROM time_test", conn )
Call the ExecuteReader method to return the DataReader object.
AsaDataReader reader = cmd.ExecuteReader();
The following code uses the GetTimeSpan method to return the time as TimeSpan.
while ( reader.Read() ) { int id = reader.GetInt32(); TimeSpan time = reader.GetTimeSpan(); }
Close the DataReader and Connection objects.
reader.Close(); conn.Close();