发布网友 发布时间:2022-04-24 11:05
共1个回答
热心网友 时间:2022-04-09 12:58
写:
说明:QueryFile字段为blod类型
private bool SaveQuery(String content)
{
byte[] byts = new System.Text.UnicodeEncoding().GetBytes(content);
assistant ast = new assistant();
MySqlParameter[] param = new MySqlParameter[5];
TimeSpan nowtimespan = new TimeSpan(DateTime.Now.Ticks);
param[0] = new MySqlParameter("@CQID", nowtimespan);
param[1] = new MySqlParameter("@userID", Session["OfficerID"].ToString());
param[2] = new MySqlParameter("@QueryFile", byts);
param[3] = new MySqlParameter("@filename", filename.Text);
param[4] = new MySqlParameter("@fcomment", Comment.Text);
ast.insertCQ(param);
return true;
}
读:
说明:2为blod数据类型的索引
protected void setSelect(String uderid)
{
String sqlcommand = String.Format("select * from CustomQuery where CQID='{0}'", uderid);
MySqlDataReader msr = dh. getReader(sqlcommand,null);
msr.Read();
Byte[] blob = new Byte[(msr.GetBytes(2, 0, null, 0, int.MaxValue))];
msr.GetBytes(2, 0, blob, 0, blob.Length);
msr.Close();
msr.Dispose();
String xmlStr = Encoding.Unicode.GetString(blob);
query.LoadFromString(xmlStr);
}
最简单就是:选出blob数据到DataTable强制类型转化为Byte[]再用 Encoding.Unicode.GetString(Byte[],)转化。追问你别复制了不中?