[Mono-list] anyone got bDataAdapter.Fill Method work?

Dennis Boylan mono@b-lan.com
Mon, 12 Jul 2004 17:22:28 -0400


I'm trying to chase this down myself.  I've got a .NET application which
runs fine under the Microsoft runtime, but I get a:

System.Data.SqlClient.SqlException: Error converting data type nvarchar to tinyint.

while trying to run the same application under mono.

I thought it was fill as well because the traceback looks like this:

in <0x00058> (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)
in [0x00092] (at /home/dennis/Dev/new/DbLayer/Network.cs:1070) IA.DbLayer.DBNetwork:GetDTNetwork (int)

Where GetDTNetwork is trying to fill a DataTable with the values from a
MS SQL database on a remote machine.  It is the last part of my application
code before it gets lost in the weeds.

I thought it might be because the table was empty, so I wrote a little
standalone app to test it.  The standalone app works.

My first test was trying it without using my stored procedure.  It was
called test2.  The second uses a stored procedure like the application
normally does.  It was called test3.

These were my best approximations of what the code at the location was
trying to do.  The real code hides the type of database, so direct examples
would not be all that useful.

Now, mind you, I'm trying this on the bleeding edge.
[dennis@Shuttle test]$ mono -V
Mono JIT compiler version 1.0.20040712, (C) 2002-2004 Novell, Inc and Contributors. www.go-mono.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV      : normal
        Globalization: ICU

- Dennis

-- test2.cs --

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

 public class Test
 {
     public static void Main(string[] args)
     {
        string connectionString =
              "Address=hp,1434;" +
              "Database=Linux;" +
              "User ID=test;" +
              "Password=test;";
        IDbConnection dbcon;
        dbcon = new SqlConnection(connectionString);
        dbcon.Open();
        IDbCommand dbcmd = dbcon.CreateCommand();
        string sql = "SELECT Name, Parent " +
	             "FROM Network";
        dbcmd.CommandText = sql;
        DataTable dtNtwk = new DataTable("Network");
        DbDataAdapter dbAdptr = new SqlDataAdapter((SqlCommand)dbcmd);
        int iRows = dbAdptr.Fill(dtNtwk);
	Console.WriteLine ("Returned " + iRows + " rows");
        dbcon.Close();
        dbcon = null;
    }
}

-- test3.cs --
 using System;
 using System.Data;
 using System.Data.Common;
 using System.Data.SqlClient;

 public class Test
 {
     public static void Main(string[] args)
     {
        string connectionString =
              "Address=hp,1434;" +
              "Database=Linux;" +
              "User ID=test;" +
              "Password=test;";
        IDbConnection dbcon;
        dbcon = new SqlConnection(connectionString);
        dbcon.Open();
        IDbCommand dbcmd = new SqlCommand("GetNtwkNEType", (SqlConnection)dbcon);
	dbcmd.CommandType = CommandType.StoredProcedure;
	IDataParameter param = ((SqlCommand)dbcmd).Parameters.Add("@AddrType", SqlDbType.TinyInt);
	param.Direction = ParameterDirection.Input;
	param.Value = 0;
        DataTable dtNtwk = new DataTable("Network");
        DbDataAdapter dbAdptr = new SqlDataAdapter((SqlCommand)dbcmd);
        int iRows = dbAdptr.Fill(dtNtwk);
	Console.WriteLine ("Returned " + iRows + " rows");
        dbcon.Close();
        dbcon = null;
    }
}


On Mon, Jul 12, 2004 at 08:40:05PM +0300, Igor Georgiev wrote:
> anyone got DbDataAdapter.Fill Method work?
> I need to deploy working .NET web application to apache/xsp/mono,
> but unfortunately i always get an empty dataset :((
> 
> ExecuteScalar & ExecuteReader works for me,  so as a last resort
> i'll rewrite the data access components to fill dataset by hand :(((
> 
> 
> I think it's a bug so i submit a report,
> but i'm very intersted does anyone get it work?
> If yes pls notify me urgent because i have a deadline to do the work .
> 
> ----- here is the copy of my bug report ----
> odbcDataAdapter.Fill(DataSet) doesn't work for me
> 
> Steps to reproduce the problem:
> 1. create odbcDataAdapter that select something from database
> 2. generate named/typed dataset /i'm using VS2003.NET /
> 3. fill dataset
> 
> Actual Results:
> dataset is empty
> 
> Expected Results:
> Data in the dataset
> 
> How often does this happen? 
> Always
> 
> Additional Information:
> Code work fine in .NET framework
> -----
> also i try public int Fill( DataTable dataTable); - same result :(((
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.718 / Virus Database: 474 - Release Date: 09.07.2004
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list