Click here to Skip to main content
15,880,427 members

An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.dll

sufiki asked:

Open original thread
Hello Everybody,

I have the following problem.

I have a large database table (inside a MS Sql-database) which I read inside a DataTable object. The DataTable object itself is bound to a DataGridView object where I show the data. Sometimes I would like to hide some data, which is not relevant for the current view. The DataView object inside the DataTable seems to be the best way to do this. DataView has a property RowFilter where you can set the visible rows. The input to RowFilter is a sql string. Unfortunately, I get a stack overflow exception when the string becomes too long. The following happens when then:

“An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.dll”

I have already tried to split the string and call RowFilter several times but this would override the old settings. The same happens when calling "Select" function from the DataTable object.

Do someone have a similar problem and find a solution.

Below, I have scheduled my code:

Thank you for all help

Sahit

C#
DataTable sourceTable = new DataTable(); 
SqlStringBuilder filter = new SqlStringBuilder();
// Set source from database

// Fill "filter" with a very large string
// Like {[intType = '1']} AND(intFamilyID = '2' OR intFamilyID = '4' OR 
   intFamilyID = '6') .........................} 
// 17 000 signs

// Here happens the problem
sourceTable.DefaultView.RowFilter = = filter.ToString();

// The same happens when trying this. 
DataRow[] resultSet = sourceTable.Select(filter.ToString());
Tags: ADO.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900