[Mono-devel-list] Filling Datatable not working

MN mn at electroputere.ro
Fri Jun 18 09:17:17 EDT 2004


THE PROBLEM I HERE TOO !

I'm making some tests of an issue reported for a user
of the Firebird .NET provider.

The problem gives filling datasets, after some debugging, the
problem seems to be in the DataRow.SetValuesFromDataRecord that
is making a call to column.DataContainer.SetItemFromDataRecord,
in my sample, that will call to
Int16DataContainer.SetItemFromDataRecord, that will do a call to the
IDataReader.GetIn16 method *without* check for nulls, a comment in that
method tells that caller should handle the exceptions but
DataRow.SetValuesFromDataRecord isn't doing that.

I think the DataRow.SetValuesFromDataRecord should be fixed for call the
IDataReader.IsDBNull method or check if a conversion exception is
thrown, and fill the column with DBNUll.Value in that case.

Am i right ?? :)



(Thew same sample program works fine in .NET)


--
Best regards

Carlos Guzmán Álvarez
Vigo-Spain

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

----- Original Message -----
From: "S Umadevi" <sUmadevi at novell.com>
To: <mono-devel-list at lists.ximian.com>; <Krieg.Andreas at OCE.DE>
Sent: Friday, June 18, 2004 12:22 PM
Subject: Re: [Mono-devel-list] Filling Datatable not working


> Hi
>   I am not able to replicate the problem with your test program. I ran it
across a sample database and I got the correct number of rows.
> Can you please let me know if I there is any more information, am I
missing anything in the setup..
>
> Can you also try to check it again with the latest dll and let me know if
the problem exists.
>
> Regards
> Uma
>
> >>> Krieg Andreas <Krieg.Andreas at OCE.DE> 6/18/2004 11:22:05 AM >>>
> Hi,
>
>
>
> This code works fine with MS.NET Runtime but with mono the datatable will
> not be filled:
>
>
>
> using System;
>
> using System.Data;
>
> using System.Data.SqlClient;
>
>
>
> namespace cdbTest
>
> {
>
>       /// <summary>
>
>       /// Zusammenfassung für Class1.
>
>       /// </summary>
>
>       class Class1
>
>       {
>
>             /// <summary>
>
>             /// Der Haupteinstiegspunkt für die Anwendung.
>
>             /// </summary>
>
>             [STAThread]
>
>             static void Main(string[] args)
>
>             {
>
>                   Console.WriteLine("Connecting");
>
>                   SqlConnection myConnection = new
> SqlConnection("server=localhost;database=customers;User
> ID=<hidden>;Password=<hidden>");
>
>                   SqlCommand myCommand = new SqlCommand("select * from
> Kunden", myConnection);
>
>                   myConnection.Open();
>
>                   Console.WriteLine("Connected");
>
> //                IDataReader dr;
>
> //                dr =
> myCommand.ExecuteReader(CommandBehavior.SingleResult);
>
> //                Console.WriteLine("Reader Executed");
>
> //                int cnt = 0;
>
> //                while (dr.Read())
>
> //                {
>
> //                      cnt++;
>
> //                      Console.WriteLine("Rec#" + cnt + " --> " +
> String.Format("{0} {1} {2} {3} {4}", dr[0], dr[1], dr[2], dr[3], dr[4]));
>
> //                      if(cnt >= 100)
>
> //                           break;
>
> //                }
>
> //                dr.Close();
>
>                   DataTable dt = new DataTable();
>
>
>
>                   SqlDataAdapter myAdapter = new SqlDataAdapter();
>
>                   myCommand.CommandType = CommandType.Text;
>
>                   myAdapter.SelectCommand = myCommand;
>
>                   myAdapter.Fill(dt);
>
>
>
>                   Console.WriteLine("Number of Records " + dt.Rows.Count);
>
>                   myConnection.Close();
>
>                   Console.WriteLine("Connection closed");
>
>                   Console.WriteLine("Press ENTER");
>
>                   Console.ReadLine();
>
>
>
>             }
>
>       }
>
> }
>
>
>
> The (commented out) DataReader stuff is working as expected, but the
> DataTable will not be filled. I also tried to fill a Dataset, but this
> doesn't work too.
>
>
>
> I read by the Sql DataProvider Page on the mono site, that filling a
> datatable should work.
>
>
>
> I used Mono Beta 3 on Windows and Mono Beta 2 on linux to check it out.
>
>
>
> Thanks for help,
>
>
>
> Andreas
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list