Bug 29420 - Bug in System.Data - DataReader can't handle sql datatype "Date" and datatype "Time" correctly
Summary: Bug in System.Data - DataReader can't handle sql datatype "Date" and datatype...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 3.12.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-27 09:09 UTC by info
Modified: 2017-09-01 09:29 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description info 2015-04-27 09:09:24 UTC
Bug Description: Error in System.Data - DataReader can't handle sql datatype "Date" and datatype "Time" correctly

Created a testcase with monodevelop and compiled under monodevelop in Debian jessie 8 64(stable) with mono runtime 3.12.1 (http://download.mono-project.com/repo/debian). 

Database:Used SQL Server 2014

Mono/Debian Compiled binaries work as expected under Windows 7 64bit. 

binaries runs on debian but fails due to the 2 casting error (se comment in testcase code).


Expected output: The values insert in database

How to run the test:
1. Create a console application (Mono / .NET 4.5) with reference to System.Data
2. Create a database table named "ContentLocales" with fields "lastUpdatedDate" and "lastUpdatedTime"
3. Insert one new item in table "ContentLocales"
4. Update the console application with the correct connection string (variable "connectionString")

//################################# Code ##############################################//
//#####################################################################################//

//Database Columns definition in table ContentLocales
[lastUpdatedDate] [date] NOT NULL,
[lastUpdatedTime] [time](7) NOT NULL,

//Console Application
public static void Main (string[] args)
{
	const string connectionString="Data Source=aaa;Initial Catalog=yyy;User Id=sa;Password=xxx";


	using (SqlConnection connection=new SqlConnection(connectionString))
	{
		connection.Open ();
		SqlCommand command = new SqlCommand ("select * from ContentLocales",connection);
		SqlDataReader reader = command.ExecuteReader();
		//Read First row Date and time
		reader.Read ();
		//Bug - object is of type string - not DateTime
		DateTime lastUpdatedDate=(DateTime)reader["LastUpdatedDate"];
		//Bug - object is of type string - not TimeSpan
		TimeSpan lastUpdatedTime=(TimeSpan)reader["LastUpdatedTime"]; 

		Console.WriteLine ("First Line -  LastUpdatedDate:{0}     LastUpdatedTime:{1}", lastUpdatedDate, lastUpdatedTime);
	}
		
}

Note You need to log in before you can comment on or make changes to this bug.