【发布时间】:2014-06-26 01:30:44
【问题描述】:
我有以下问题。 我有一个有 26 列的表。一些列是 tinyblob 或 blob 列。存储在这些 blob 列中的数据格式为:
0000 0010 0005 0400 0365
0000 0020 0041 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;
}
我想要做的是将 tinyblob 作为字节数组并将其称为一个,例如
byte[] MyBLOB = functions.GetData("John213");
MessageBox.Show(string.format("{0}", MyBLOB[0])); //0
MessageBox.Show(string.format("{0}", MyBLOB[2])); //5
MessageBox.Show(string.format("{0}", MyBLOB[4])); //869
这可能吗?提前谢谢你。
【问题讨论】: