Large tables cause constraint exception in MySqlDataTable

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
pjcrosbie
Posts: 2
Joined: Mon 03 Jan 2005 20:41

Large tables cause constraint exception in MySqlDataTable

Post by pjcrosbie » Thu 13 Jan 2005 03:24

I get the following error message when trying to read a very large datatable.

An unhandled exception of type 'System.Data.ConstraintException' occurred in system.data.dll

Additional information: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.


The code works fine with small tables even when the small tables have nulls and no keys. The code always fails on large tables even when there are no nulls and unique keys. Does anyone have any clues? Is there a limit to the size of tables you can load into a MySqlDataTable (and MySQLDataSet)?

Code: Select all

static void MySQLDirect()
		{
			string strConnect, strQuery;
			strConnect = "Host=EvoW4000; User=pjc; Password=timaru; Database=BCResearch";
			strQuery = "Select * from _dd_fields";
			MySqlConnection db = new MySqlConnection(strConnect);
			db.Open();
			MySqlCommand dbCommand = new MySqlCommand(strQuery, db);	
			string val;
			try
			{
				int rowID = 0;
				MySqlDataTable dt = new MySqlDataTable(dbCommand);
				dt.Constraints.Clear();
				dt.Active = true;
				foreach (DataRow currRow in dt.Rows)
				{
					Console.WriteLine("Record Start {0}", rowID++);
					int colID = 0;
					foreach (DataColumn currCol in dt.Columns)
					{
						val = currRow[currCol].ToString();
						Console.WriteLine("{0} \t {1}", colID++, val);
					}
					Console.WriteLine("Record End");
				} 
				dt.Dispose(); 
			} 
			finally 
			{ 
				db.Close(); 
			} 
		}
	}

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: Large tables cause constraint exception in MySqlDataTable

Post by Oleg » Thu 13 Jan 2005 15:50

Please send your example to our support email address and include a script to create and fill with data a test table.

Hammo

Similar Problem

Post by Hammo » Thu 20 Jan 2005 01:35

I have exactly this problem occuring on a small table ???

Also, I would suggest that you guys simplify the documentation with soime tutorials and 'Getting Started' kind of stuff. I'm new to VB NET and struggling with that already.

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: Similar Problem

Post by Oleg » Fri 21 Jan 2005 12:04

We have already fixed this problem and this fix will be included in the nearest build of MySQLDirect .NET.

Post Reply