C#ODBC将tinyblob和blob作为字节数组获取

C#ODBC将tinyblob和blob作为字节数组获取,c#,arrays,odbc,byte,blob,C#,Arrays,Odbc,Byte,Blob,我有以下问题。 我有一个有26列的表。有些列是tinyblob或blob列。存储在这些blob列中的数据的格式为: 0000 0010 0005 0400 0365 0000 00200041 0251 0023 我使用以下代码获取所选内容的行: try { string[] CurrentCons; mysql.command = new OdbcCommand("SEL

我有以下问题。 我有一个有26列的表。有些列是tinyblob或blob列。存储在这些blob列中的数据的格式为:

0000 0010 0005 0400 0365
0000 00200041 0251 0023

我使用以下代码获取所选内容的行:

            try

             {

                 string[] CurrentCons;
                 mysql.command = new OdbcCommand("SELECT * FROM current.cons_list WHERE name = ?", mysql.connection);
                 mysql.command.Parameters.Add("name", OdbcType.VarChar).Value = nick;
                 mysql.myReader = mysql.command.ExecuteReader();
                 CurrentCons = new string[mysql.myReader.FieldCount];
                 mysql.myReader.Read();

                 for (int i = 0; i < CurrentCons.Length; i++)
                 {
                     CurrentCons[i] = mysql.myReader[i].ToString();
                 }
                 return CurrentCons;
             }
             catch(Exception ex)
             {
                 string[] CurrentCons;
                 LOG.WriteLog("(" + DateTime.Now + ")\t" + ex.Message + "\t" + ex.Source + "\t" + ex.InnerException + "\n");
                 CurrentCons = new string[0];
                 return CurrentCons;
             }

可能吗?提前谢谢。

将blob读入字节数组的方法是通过
GetBytes()
方法

int length; //the width of the blob
byte[] buffer = new byte[length];
reader.GetBytes(reader.GetOrdinal("John123"), 0, buffer, 0, length);

仅供参考,
GetBytes()
在C#中的大多数DataReader类上都可用

int length; //the width of the blob
byte[] buffer = new byte[length];
reader.GetBytes(reader.GetOrdinal("John123"), 0, buffer, 0, length);