Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7767795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:45:47+00:00 2026-06-01T15:45:47+00:00

I have an application using LINQ-to-SQL with SQL Server CE 4. I know that

  • 0

I have an application using LINQ-to-SQL with SQL Server CE 4. I know that this isn’t officially supported, but we have made it work, with the following exception. On occasion, we get an error with a row in the database when trying to update it.

We use a DataContext to select a row from the database, update a few columns (a boolean and a byte column), then we call SubmitChanges(). When we submit the changes, we are getting a DivideByZeroException with the following stack trace:

System.DivideByZeroException: Attempted to divide by zero.
at System.Data.SqlServerCe.NativeMethodsHelper.CompileQueryPlan(IntPtr
pQpCommand, String pwszCommandText, ResultSetOptions options, IntPtr[]
pParamNames, IntPtr prgBinding, Int32 cDbBinding, IntPtr& pQpPlan,
IntPtr pError)
at System.Data.SqlServerCe.NativeMethods.CompileQueryPlan(IntPtr pQpCommand, String pwszCommandText, ResultSetOptions options, IntPtr[]
pParamNames, IntPtr prgBinding, Int32 cDbBinding, IntPtr& pQpPlan,
IntPtr pError)
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior
behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[]
parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object
lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[]
userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression
query)
at System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicUpdate(TrackedObject
item)
at System.Data.Linq.ChangeDirector.StandardChangeDirector.Update(TrackedObject
item)
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges()

EDIT:

Upon profiling, the problem appears to be generated on a delete statement, similar to this:

DELETE FROM [WorkItemUid]
WHERE ([Oid] = 24151 /* @p0 /)
AND ([WorkItemOid] = 745 /
@p1 /)
AND ([SeriesInstanceUid] = ‘1.3.12.2.1107.5.1.4.54023.30000004101914490887500000063’ /
@p2 /)
AND ([SopInstanceUid] = ‘1.3.12.2.1107.5.1.4.54023.30000004101913521221800001089’ /
@p3 /)
AND ([Complete] = 1)
AND ([FailureCount] = 0 /
@p4 */)
AND ([File] IS NULL)
AND (NOT ([Failed] = 1))

The error was happening in a statement where I was attempting to individually delete ~1500 foreign key records. When I changed the code to delete rows individually, I narrowed it down to about 45 rows that couldn’t be deleted. I then used SQL Compact Query Analyzer to attempt to execute the delete on the lines themselves, and it did fail there also, with the divide by zero exception.

So, it appears to not be a Linq-to-Sql error, but rather something with SQL Server Compact CE 4.0 itself deleting these rows. I’ve attempted to delete and start with a clean database, and replicated the populating and then deleting from the database, and the problem happens again. It might be an issue when there’s > 1500 foreign key records that something happens when deleting.

A bunch of google searches were mostly empty, but I did find a reference to a DivideByZeroException with SQL Server CE 3.5 at this reference. I have confirmed I’m using the SQL Server CE 4.0 assemblies, so this does not seem to be the issue. Any ideas on if the above bug still applies to SQL Server CE 4.0? It appears after further review it is the same problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:45:48+00:00Added an answer on June 1, 2026 at 3:45 pm

    Upgrading to SQL Server Compact CTP1 appears to have resolved the problem. I am no longer seeing the exceptions when deleting rows as reported in the question. The problem appeared to be related to deleting rows from a table where there were > 1500 rows in a foreign key relationship.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a forum application using asp.net, c#, sql server and linq to sql.
I have a web application using ASP.NET 2.0 and I want to know if
I have a pretty big web application that I created last year using ASP.NET
I have an ASP.NET MVC 3 application with a SQL Server 2005 database backend.
I created one asp.net mvc application using linq to sql, and in the generated
I am using Full Text Search with LINQ in my application and as this
I have a C# console application which simply pulls information from a Sql Server
I've taken over an application using linq-to-sql and now plan to do some major
I am using visual studio 2010, (desktop application) and using LINQ to SQL to
I have created a small test for updating table using Linq-to-SQL DataContext as follows:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.