Bug 55767 - System.Data.SqlClient returns varchar from char column
Summary: System.Data.SqlClient returns varchar from char column
Status: NEEDINFO
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-04-29 06:50 UTC by j_connor
Modified: 2017-09-29 15:46 UTC (History)
2 users (show)

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


Attachments

Description j_connor 2017-04-29 06:50:17 UTC
This is partial source code from where the error happens


public Table<Tbl_User_Inf> Tbl_User_Inf
{
	get
	{
		return base.GetTable<Tbl_User_Inf>();
	}
}

public VeraDataContext() : base(ConfigurationManager.ConnectionStrings["DiceConnectionString1"].ConnectionString, VeraDataContext.mappingSource)
{
}

VeraDataContext veraDataContext = new VeraDataContext()
int num = veraDataContext.Tbl_User_Inf.Count((Tbl_User_Inf r) => r.User_Id == UserID && r.User_Pwd == Password && (int)r.User_DelState == 78 && (int)r.IsBlocked == 78);


In DB (SQL Server 2008 R2), User_DelState is char
In IIS 7.5(Windows Server 2008 R2), r.User_DelState returns N
In Mono, r.User_DelState returns 'N'
Thus, Mono failed to cast to int and prints this error


X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319



System.Data.SqlClient.SqlException
Conversion failed when converting the varchar value &#39;N&#39; to data type int.


 at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object sender, Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00066] in &lt;acd8058a155649249a9fcf2f89526586&gt;:0 
  at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage (Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x0000b] in &lt;5bf15fa782b6409b807a07461c1a183d&gt;:0 
  at Mono.Data.Tds.Protocol.Tds.ProcessMessage (Mono.Data.Tds.Protocol.TdsPacketSubType subType) [0x00102] in &lt;5bf15fa782b6409b807a07461c1a183d&gt;:0 
  at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x0012a] in &lt;5bf15fa782b6409b807a07461c1a183d&gt;:0 
  at Mono.Data.Tds.Protocol.Tds.NextRow () [0x00027] in &lt;5bf15fa782b6409b807a07461c1a183d&gt;:0 
  at System.Data.SqlClient.SqlDataReader.ReadRecord () [0x00052] in &lt;acd8058a155649249a9fcf2f89526586&gt;:0 
  at System.Data.SqlClient.SqlDataReader.Read () [0x0001c] in &lt;acd8058a155649249a9fcf2f89526586&gt;:0 
  at DbLinq.Data.Linq.Sugar.Implementation.QueryRunner.Select[T] (DbLinq.Data.Linq.Sugar.SelectQuery selectQuery) [0x000e1] in &lt;e09e3e04f4674f8f96cb303c4f9e51dd&gt;:0 
  at DbLinq.Data.Linq.Sugar.Implementation.QueryRunner.SelectSingle[S] (DbLinq.Data.Linq.Sugar.SelectQuery selectQuery, System.Boolean allowDefault) [0x0000c] in &lt;e09e3e04f4674f8f96cb303c4f9e51dd&gt;:0 
  at DbLinq.Data.Linq.Sugar.Implementation.QueryRunner.SelectScalar[S] (DbLinq.Data.Linq.Sugar.SelectQuery selectQuery) [0x00062] in &lt;e09e3e04f4674f8f96cb303c4f9e51dd&gt;:0 
  at DbLinq.Data.Linq.Implementation.QueryProvider`1[T].Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00013] in &lt;e09e3e04f4674f8f96cb303c4f9e51dd&gt;:0 
  at System.Linq.Queryable.Count[TSource] (System.Linq.IQueryable`1[T] source, System.Linq.Expressions.Expression`1[TDelegate] predicate) [0x00059] in &lt;2392cff65f724abaaed9de072f62bc4a&gt;:0 
  at Vera.Controllers.PcAccountController.LoginCheck (System.String UserID, System.String UserPassword) [0x001e9] in &lt;ec854fb3523d4c4e9429c304cb627169&gt;:0 
  at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[])
  at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc.ControllerBase controller, System.Object[] parameters) [0x00000] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc.ControllerContext controllerContext, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters) [0x00079] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionDescriptor actionDescriptor, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters) [0x00000] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionDescriptor actionDescriptor, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters) [0x00000] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker+&lt;&gt;c__DisplayClass42.&lt;BeginInvokeSynchronousActionMethod&gt;b__41 () [0x00000] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncResultWrapper+&lt;&gt;c__DisplayClass8`1[TResult].&lt;BeginSynchronous&gt;b__7 (System.IAsyncResult _) [0x00000] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[TResult].End () [0x00029] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod (System.IAsyncResult asyncResult) [0x00000] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker+&lt;&gt;c__DisplayClass37+&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33 () [0x0001e] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker+&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49 () [0x00002] in &lt;239167677e3a4fabad850bb94082b2dd&gt;:0 

Version Information: 4.8.1 (Stable 4.8.1.0/22a39d7 Wed Apr 12 12:00:40 UTC 2017); ASP.NET Version: 4.0.30319.42000
Comment 1 Marek Safar 2017-09-29 15:46:15 UTC
Thank you for your report!

I’m unable to reproduce this issue locally using the information you provided. In order to investigate the issue further can you please attach a reproduction project and steps to reproduce this issue? For help on writing a bug report, please see our guide on this topic:

https://bugzilla.xamarin.com/page.cgi?id=bug-writing.html

Some of your next steps would be:

1. Including a sample project or steps to reproduce this problem
2. Your Version Information
3. Your expected results and actual results

Thank you!

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