我得到:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 ''spectra' WHERE specId=42' 附近使用正确的语法
运行此代码时:
public System.Drawing.Image GetImage(int index)
{
using (MySqlCommand command = connection.CreateCommand())
{
//command.CommandText = "SELECT imageObj FROM spectra WHERE specId=42"; <== Works OK!
command.CommandText = "SELECT imageObj FROM @tname WHERE specId=@index";
command.Parameters.AddWithValue("@index", index);
command.Parameters.AddWithValue("@tname", "spectra");
using (MySqlDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
return (System.Drawing.Image)Serial.ByteArrayToObject((byte[])reader[0]);
}
}
}
return null;
}
我认为问题在于频谱周围的引号。我怎样才能删除它们?