I have a query to get a Name (string) and Value (byte[]) from a MySQL table. The query is all executing, because if I put a breakpoint on the final line, I can look at the data DataTable and see the records with the Name field populated. However, the Value field is null.
我有一个从MySQL表中获取名称(字符串)和值(byte[])的查询。查询都在执行,因为如果我在最后一行放上断点,我就可以查看数据数据表,并看到填充了名称字段的记录。但是,值字段为空。
var queryString = "SELECT Name, DECOMPRESS(Value) FROM myTable";
var query = new MySqlQuery(myMySqlConnection, queryString);
var data = new DataTable();
try
{
// Tried to execute first, no change
// query.ExecuteNonQuery();
var da = new MySqlDataAdapter(query);
await da.FillAsync(data);
}
finally
{
await connection.CloseAsync();
}
results = JArray.FromObject(data).ToObject<List<Record>>();
If I remove DECOMPRESS from the query, I get the expected data (just compressed which isn't useful to me).
如果我从查询中删除解压缩,我会得到预期的数据(只是压缩,对我来说没有用处)。
I have also tried putting putting data.Load(reader)
in a while(reader.Read())
loop, but this throws an exception due to the Reader being closed.
我也曾尝试将data.Load(Reader)放入一个While(Reader.Read())循环中,但由于Reader被关闭,因此引发了一个异常。
Do I need to do something to get the uncompressed data into my DataTable?
我需要做些什么才能将未压缩的数据放入我的数据表中吗?
更多回答
SELECT Name, DECOMPRESS(Value) AS Value...
maybe?
选择名称,解压缩(值)作为值...也许吧?
If it's that simple I'm going to be so angry :P I'll test and get back to you.
如果真的这么简单,我会很生气的:P,我会测试,然后给你回复。
@Charlieface write an answer, points are all yours. A full workday I've spent on this.
@CharlieFace写一个答案,积分都是你的。我在这上面花了整整一个工作日。
优秀答案推荐
You need to give the column an alias:
您需要为该列指定别名:
SELECT Name, DECOMPRESS(Value) AS Value
FROM ...
更多回答
我是一名优秀的程序员,十分优秀!