[Mono-list] MySqlDataAdapter.Fill uses strings for binary columns - any help? Are Binary Guids doable?

Pxtl martin.zarate at gmail.com
Sun Nov 9 12:00:48 EST 2008


I'm just getting started with Mono/MySQL and I'm hitting a wall with using
Guids.

The following code demonstrates the problem:


		MySqlConnection conn = new
MySqlConnection(@"Server=localhost;Database=qa;uid=asp_net;pwd=password;");
		conn.Open();
		using(MySqlCommand cmd = new MySqlCommand(@"
delete from service_types;
insert into service_types(id, name) values(?id, 'test');", conn))
		{
			cmd.Parameters.AddWithValue("?id", Guid.NewGuid().ToByteArray());
			cmd.ExecuteNonQuery();
		}
		
		using(MySqlCommand cmd = new MySqlCommand(@"
select * from service_types", conn))
		{
			MySqlDataAdapter ad = new MySqlDataAdapter(cmd);
			DataTable res = new DataTable();
			ad.Fill(res);
			entryPopulate.Text = res.Rows[0]["id"].GetType().ToString();
		}


"id" is a Binary(16) column, as is recommended for storing Guids.

The problem: while the Guid goes into the database just fine, it comes back
as a "System.String".  This makes it impossible to fetch any binary data -
particularly guids - out of the database.  I've tried it with the InnoDB and
MyISAM storage engines, and it's always a String.

I'm using 1.9.1, with Connector/NET 5.0.8, which is what is available in the
Ubuntu package managers.  Is there a download for newer Connector/NET
Mono-compatible DLLs that I could be using for my project?  So far I've been
finding this version of Connector/NET to be barely functional - no
MySqlDataAdapter.Update(), it doesn't work with SqlDataSource, and it
doesn't seem to work with binary data.

Help!
-- 
View this message in context: http://www.nabble.com/MySqlDataAdapter.Fill-uses-strings-for-binary-columns---any-help---Are-Binary-Guids-doable--tp20408334p20408334.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list