MySqlDataReader.GetBytes() problem, my mistake or bug
Posted by: Gary Byatt
Date: September 28, 2006 01:41AM

Hi all
Probably my mistake, but I can't see where it is, can anyone help...

MySqlDataReader.GetBytes() throws this exception:
MySql.Data.MySqlClient.MySqlException: GetBytes can only be called on binary columns

A simplified version of the code it occurs on:
MySqlDataReader resultSet =
DBConnection.ExecuteQuery("SELECT fileId,fileHash,fileName FROM filesummary");
byte[] sha1 = new byte[20];
while(resultSet.Read()) { bytesFound = resultSet.GetBytes(1, 0L, sha1, 0, 20);

The table definition:
CREATE TABLE `filesummary` (
`fileId` bigint(20) unsigned NOT NULL default '0',
`fileHash` binary(20) NOT NULL,
`fileName` varchar(255) NOT NULL default '',
PRIMARY KEY (`fileId`),
KEY `Index_fileName` (`fileName`),
KEY `Index_fileHash` (`fileHash`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Something that looks wrong:
resultSet.GetFieldType(1) returns System.String
Which explains why resultSet.GetString(1) returns a value, although not useful, and GetBytes() throws the exception.
I checked with MySQL Administrator, the field shows as binary(20).

I am using:
MySQL 5.0.24a
.Net2.0 connector 1.07.30072
CLR v2.0.50727 on XP SP2

Any ideas what I am doing wrong?
Many thanks
Gary



Edited 2 time(s). Last edit at 09/29/2006 02:47AM by Gary Byatt.

Options: ReplyQuote


Subject
Written By
Posted
MySqlDataReader.GetBytes() problem, my mistake or bug
September 28, 2006 01:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.