[Mono-bugs] [Bug 61177][Wis] Changed - ExecuteReader.read() value is false

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 5 Jul 2004 12:43:11 -0400 (EDT)


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 bogdan.avram@ulpmm.u-strasbg.fr.

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

--- shadow/61177	2004-07-05 12:32:56.000000000 -0400
+++ shadow/61177.tmp.30927	2004-07-05 12:43:11.000000000 -0400
@@ -54,6 +54,119 @@
 How often does this happen? 
 
 every time (100% fail)
 
 
 Additional Information:
+
+------- Additional Comments From bogdan.avram@ulpmm.u-strasbg.fr  2004-07-05 12:43 -------
+SqlConnection cnc = new SqlConnection ();
+cnc.ConnectionString =  "SERVER=127.0.0.1"
+				+";DATABASE=DevAcolad" 
+				+";user id=DebianEEN"
+				+";password=sssss";
+SqlCommand callStoredProcCommand = cnc.CreateCommand ();
+callStoredProcCommand.CommandType = CommandType.StoredProcedure;
+callStoredProcCommand.CommandText="Cours_RestaureCours";
+callStoredProcCommand.Parameters.Add(new SqlParameter
+("@Id",TdsType.UniqueIdentifier,16,"IdCours"));
+callStoredProcCommand.Parameters[0].Value=new Guid("B19C5096-6A0C-
+4F8E-A622-A6B9B4C8AA64");
+DataSet ds=convertDataReaderToDataSet
+(callStoredProcCommand.ExecuteReader());
+
+
+static DataSet convertDataReaderToDataSet(IDataReader reader)
+		{
+			DataSet dataSet = new DataSet();
+			do
+			{
+				// Create new data table
+
+				
+				DataTable schemaTable = 
+reader.GetSchemaTable();				
+				DataTable dataTable = new DataTable();
+
+				if ( schemaTable != null )
+				{
+					// A query returning records 
+was executed
+
+					for ( int i = 0; i < 
+schemaTable.Rows.Count; i++ )
+					{
+						Console.WriteLine(i);
+						DataRow dataRow = 
+schemaTable.Rows[ i ];
+						// Create a column 
+name that is unique in the data table
+						string columnName = ( 
+string )dataRow[ "ColumnName" ]; //+ "<C" + i + "/>";
+						// Add the column 
+definition to the data table
+						Console.WriteLine((( 
+Type )dataRow[ "DataType" ]).ToString());
+						DataColumn column = 
+new DataColumn( columnName, ( Type )dataRow[ "DataType" ] );
+						Console.WriteLine
+(column.ToString());						
+						dataTable.Columns.Add
+( column );
+					}
+
+					dataSet.Tables.Add( 
+dataTable );
+
+					// Fill the data table we 
+just created
+					//Console.WriteLine
+(reader.HasRowsnull);
+					//Console.WriteLine
+("Read "+reader.Read());					 
+					while ( reader.Read() )
+					{
+						Console.WriteLine
+("start while reader");
+						//Console.WriteLine
+(reader.GetSqlString(0).ToString() + ", " + reader.GetInt32(1));
+						DataRow dataRow = 
+dataTable.NewRow();
+						Console.WriteLine
+("Field"+reader.FieldCount.ToString());				
+		
+
+						for ( int i = 0; i < 
+reader.FieldCount; i++ )
+						{
+						
+	Console.WriteLine("Value"+reader.GetValue( i ).ToString());
+							dataRow[ i ] 
+= reader.GetValue( i );
+						}
+
+						dataTable.Rows.Add( 
+dataRow );
+					}
+					Console.WriteLine("End while 
+reader");
+				}
+				else
+				{
+					// No records were returned
+
+					DataColumn column = new 
+DataColumn("RowsAffected");
+					dataTable.Columns.Add(column);
+					dataSet.Tables.Add( 
+dataTable );
+					DataRow dataRow = 
+dataTable.NewRow();
+					dataRow[0] = 
+reader.RecordsAffected;
+					dataTable.Rows.Add( dataRow );
+				}
+			}
+			while ( reader.NextResult() );		
+			Console.WriteLine(dataSet.DataSetName);
+			return dataSet;
+		}