[Mono-devel-list] SqlClient - DataSet stange behavior

S Umadevi sUmadevi at novell.com
Tue Aug 17 05:39:03 EDT 2004


Hi
  There was a problem with the dataset that was fixed couple of weeks
back. The symptoms of the problem are similar.. Can you please pick up
the latest code from CVS (mono-1-0 or HEAD ) and try again.

Incase it still doesnt work, can you also please send the dump of the
database table that you are accessing.

Thanks
uma

  
  

>>> "Miguel Bazzano" <mbazzano at dirinfo.unt.edu.ar> 8/12/2004 11:01:10
PM >>>
Hi,
 
I am fairly new to mono but not to .net. I don't know if this is the
correct
list to post to, but anyway.

 
Here is my problem:

In the following short program (at the end of the message) the DataSet
loop
does not work, i.e.: the Fill command of the SqlDataAdapter does not
put any
rows into the dataset, leaving and empy Rows collection, the data
however is
there as the DataReader part works perfectly (in fact I only included
it to
test that I have access to the data). What is stranger is the fact that
this
happen with only some databases, I tried both the Northwind and Pubs
databases and they don't have the same behavior (they work ok with
both
methods). Of course both methods work ok from .NET under Windows with
all
databases. I tried compiling under windows and Linux Fedora 2 (Mono
1.0.1)
and the problem persists. 

Any help will be greatly appreciated as this is driving me crazy,

Regards,

Miguel Bazzano
 

Program Example:

using System;
using System.Data;
using System.Data.SqlClient;


class MainClass
{
	public static void Main(string[] args)
	{
		Console.WriteLine("Prueba desde linux");
		
		SqlConnection cnn1 = new SqlConnection("Data
Source=olap;UID=sa;PWD=xxx;Initial Catalog=Usuarios");
		cnn1.Open();
		Console.WriteLine(cnn1.State);
		DataSet dat = new DataSet();
		SqlCommand cmd = new SqlCommand("select top 100 * from
usuarios",cnn1);		

		SqlDataReader datr = cmd.ExecuteReader();
		Console.WriteLine(datr.RecordsAffected);
		Console.ReadLine();
		while (datr.Read())
		{
			Console.WriteLine(datr.GetValue(1));
		}
		//Works OK
		datr.Close();
		
		Console.ReadLine();
		
		System.Data.SqlClient.SqlDataAdapter dta = new
SqlDataAdapter(cmd);
		System.Data.DataTable dt = new DataTable();
		dta.Fill(dat);
		Console.WriteLine(dat.Tables.Count); //Returns 1
		Console.WriteLine(dat.Tables[0].Rows.Count); //Returns
0
		//dat.Tables[0].Rows.Add(
		Console.ReadLine();
		foreach (DataRow dr in dat.Tables[0].Rows)
		{
			Console.WriteLine(dr[1]);
		}
		
		cnn1.Close();
		
		
	}
}

_______________________________________________
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