Having problem after switching from mySQL to MsSql

Having problem after switching from mySQL to MsSql

Postby Zero-G. » Sun 17 Nov 2013 18:08

Hey

I use the following LinQ Query in my dotConnect for mySQL Environment with best reuslts:
Code: Select all
Dim myCustomers = (From myQuery In myDataContext.auftrags Join myDetail In myDataContext.auftragdetails On myQuery.id Equals myDetail.auftragid Where _
                           myDetail.icode = iCode And _
                           myQuery.bewegung = 0 And _
                           myQuery.auftrag1 = "Kontaktlinse" And _
                           myQuery.kundenstamm.firmenid = firmenId And
                           (myQuery.lot_re Is DBNull.Value Or _
                           myQuery.lot_li Is DBNull.Value) Order By myQuery.kundenstamm.nname, myQuery.kundenstamm.vname
                           Select New Klasse.ClsLotNummer With _
                                  {.Id = myQuery.id, _
                                   .Name = String.Format("{0}, {1}", myQuery.kundenstamm.nname, myQuery.kundenstamm.vname), _
                                   .SphRe = If(myQuery.sph_re.HasValue, myQuery.sph_re.Value, 0), _
                                   .CylRe = If(myQuery.cyl_re.HasValue, myQuery.cyl_re.Value, 0), _
                                   .AchseRe = If(myQuery.achse_re.HasValue, myQuery.achse_re.Value, 0), _
                                   .SphLi = If(myQuery.sph_li.HasValue, myQuery.sph_li.Value, 0), _
                                   .CylLi = If(myQuery.cyl_li.HasValue, myQuery.cyl_li.Value, 0), _
                                   .AchseLi = If(myQuery.achse_li.HasValue, myQuery.achse_li.Value, 0), _
                                   .ArtikelRe = myQuery.auftragdetails.Where(Function(reDetail) reDetail.zuordnung = 1).SingleOrDefault.artikelbezeichnung, _
                                   .ArtikelLi = myQuery.auftragdetails.Where(Function(liDetail) liDetail.zuordnung = 2).SingleOrDefault.artikelbezeichnung}).ToList

When I use the same with the dotConnect for MsSQL Environment, I get the following error
Code: Select all
Unexpected Typcode: DBNull

StackTrace:
Code: Select all
   bei System.Data.Linq.SqlClient.SqlTypeSystem.Sql2005Provider.From(Type type, Nullable`1 size)
   bei System.Data.Linq.SqlClient.SqlTypeSystem.Sql2008Provider.From(Type type, Nullable`1 size)
   bei System.Data.Linq.SqlClient.SqlTypeSystem.ProviderBase.From(Type type)
   bei System.Data.Linq.SqlClient.SqlTypeSystem.ProviderBase.From(Object o)
   bei System.Data.Linq.SqlClient.SqlFactory.ValueFromObject(Object value, Type clrType, Boolean isClientSpecified, Expression sourceExpression)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInvocation(InvocationExpression invoke)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitCast(UnaryExpression c)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitCast(UnaryExpression c)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitWhere(Expression sequence, LambdaExpression predicate)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitOrderBy(Expression sequence, LambdaExpression expression, SqlOrderType orderType)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitThenBy(Expression sequence, LambdaExpression expression, SqlOrderType orderType)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitSelect(Expression sequence, LambdaExpression selector)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc)
   bei System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
   bei System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(Expression node)
   bei System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)
   bei System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   bei System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   bei System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   bei VOPT.frmLotNummerZuweisung.LoadData(Int64 iCode, Int64 firmenId) in C:\Users\IntelliSoft\Documents\Visual Studio 2010\Projects\Visual OPT .NET\Vopt\VOPT\Formulare\frmLotNummerZuweisung.vb:Zeile 4.
   bei VOPT.frmLagerzugang.cmdSpeichern_Click(Object sender, EventArgs e) in C:\Users\IntelliSoft\Documents\Visual Studio 2010\Projects\Visual OPT .NET\Vopt\VOPT\Formulare\frmLagerzugang.vb:Zeile 85.
   bei System.Windows.Forms.Control.OnClick(EventArgs e)
   bei Janus.Windows.EditControls.UIButton.OnClick(EventArgs e)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei Janus.Windows.EditControls.UIButton.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.RunDialog(Form form)
   bei System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   bei System.Windows.Forms.Form.ShowDialog()
   bei VOPT.frmHauptmenue.ExplorerBar_ItemClick(Object sender, ItemEventArgs e) in C:\Users\IntelliSoft\Documents\Visual Studio 2010\Projects\Visual OPT .NET\Vopt\VOPT\Formulare\frmHauptmenü.vb:Zeile 36.
   bei Janus.Windows.ExplorerBar.ExplorerBar.OnItemClick(ItemEventArgs e)
   bei Janus.Windows.ExplorerBar.ExplorerBar.i(ExplorerBarItem )
   bei Janus.Windows.ExplorerBar.ExplorerBarItem.InvokeOnClick()
   bei Janus.Windows.ExplorerBar.ExplorerBar.OnMouseUp(MouseEventArgs e)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.RunDialog(Form form)
   bei System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   bei System.Windows.Forms.Form.ShowDialog()
   bei VOPT.VisualOPTNet.Init() in C:\Users\IntelliSoft\Documents\Visual Studio 2010\Projects\Visual OPT .NET\Vopt\VOPT\Modul\VisualOPTNet.vb:Zeile 26.
   bei VOPT.Start.Main() in C:\Users\IntelliSoft\Documents\Visual Studio 2010\Projects\Visual OPT .NET\Vopt\VOPT\Modul\Start.vb:Zeile 40.
Zero-G.
 
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Re: Having problem after switching from mySQL to MsSql

Postby MariiaI » Mon 18 Nov 2013 10:50

According to the stack trace of the error, it is not related to LinqConnect.
Please recreate your LinqConnect model for SQL Server performing the steps from this thread. After you have made all the steps correctly (without any manual changes), try your code again and notify us about the results.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)