[Mono-bugs] [Bug 76433][Nor] New - AllowDbNull property not set according to the database schema.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Oct 13 17:38:39 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien.robitaille at croesus.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76433

--- shadow/76433	2005-10-13 17:38:39.000000000 -0400
+++ shadow/76433.tmp.9573	2005-10-13 17:38:39.000000000 -0400
@@ -0,0 +1,94 @@
+Bug#: 76433
+Product: Mono: Class Libraries
+Version: 1.1
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: sebastien.robitaille at croesus.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: AllowDbNull property not set according to the database schema.
+
+Description of Problem:
+
+When filling a DataSet using the SqlDataAdapter, all the fields in a 
+table have the property AllowDbNull set to True even if the fields were 
+created with "NOT NULL".
+
+Steps to reproduce the problem:
+1. Execute the following test case:
+
+SqlConnection conn = new SqlConnection();
+conn.ConnectionString = "<fill connection string>";
+try
+{
+	conn.Open();
+	IDbCommand command = conn.CreateCommand();
+			
+	// Create table
+	command.CommandText = "create table MyTestTable (MyField1 DECIMAL
+(10) NOT NULL, MyField2 DECIMAL(19))";
+	command.ExecuteNonQuery();
+
+	DataSet dataSet = new DataSet();
+	try
+	{
+		// The following query retrieves no data by design. This 
+technique is used to
+		// retrieve the database schema with ADO.NET while 
+avoiding to retrieve needless 
+		// data at this point.
+		string selectString = "SELECT * FROM MyTestTable WHERE 
+1=0";
+		IDbDataAdapter dataAdapter = new SqlDataAdapter
+(selectString,conn);
+		dataAdapter.FillSchema(dataSet, SchemaType.Mapped);
+	}
+	catch
+	{
+	}
+
+	if(dataSet.Tables.Count == 1)
+	{
+		System.Console.WriteLine("Column 0 AllowDbNull: " + 
+dataSet.Tables[0].Columns[0].AllowDBNull.ToString());
+		System.Console.WriteLine("Column 1 AllowDbNull: " + 
+dataSet.Tables[0].Columns[1].AllowDBNull.ToString());
+	}
+
+	// Drop the table.
+	try
+	{
+		command.CommandText = "drop table MyTestTable";
+		command.ExecuteNonQuery();
+	}
+	catch {}
+}
+catch
+{
+}
+
+Actual Results:
+Column 0 AllowDbNull: True
+Column 1 AllowDbNull: True
+
+
+Expected Results:
+Column 0 AllowDbNull: False
+Column 1 AllowDbNull: True
+
+How often does this happen? 
+Always
+
+Additional Information:
+This problem does not seem to be related to SqlClient since the problem 
+also arises with SybaseClient when using Mono on Linux but not when using 
+the same Mono assemblies with MS.NET (Mono.Data.SybaseClient.dll and 
+Mono.Data.Tds.dll).


More information about the mono-bugs mailing list