dataAdapter.Fill() problem

Hi all,

I have a small fragment of code that is puzzling me… It works fine in C# .Net 2.0 In visual studio, but when using it in Unity, some strange problems occur.

This is the code I usually use to return a datatable from a database:

DataTable ret = new DataTable();
MySqlCommand cmd = new MySqlCommand(sql, connection);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(ret);

This is the error that I get in Unity:

The best overloaded method match for System.Data.Common.DataAdapter.Fill(System.Data.DataSet)' has some invalid arguments. Cannot convert System.Data.DataTable’ expression to type `System.Data.DataSet’

Also, when I use a dataset instead, I get the same error, just stating that dataset cannot be converted to dataset!!

What can I be doing wrong? What can I do to work around this?

Thanks in advance! :slight_smile:

Seems like you might have to include System.Data.dll Mono in your assets folder

Thanks NA-RA-KU, good suggestion. :smile: I do however already have System.Data.dll in the plugins folder… It is very strange, I think it must be a Mono problem. As I said, intellisense detects the Fill method and all of it’s overloads, it just wont seem to accept any!

I have made a bit of a work around, if anyone was trying to do this in the future… Using the MySqlDataReader you can read the rows, create a DataTable with the relevant amount of rows and the correct row names, and then fill the datatable with rows. :smile: