1

我需要能够更新二进制表,我这样做:

View v = session.Database.OpenView("SELECT `Data` FROM `Binary` WHERE `Name` = '{0}'", binaryKeyName);

            v.Execute();

            var IsReadOnly = session.Database.IsReadOnly;

            Record r = v.Fetch();

            StreamReader reader = new StreamReader(r.GetStream("Data"));
            string text = reader.ReadToEnd();
            text = text.Replace(@"Test12345", "TTTest");

            byte[] byteArray = Encoding.ASCII.GetBytes(text);
            MemoryStream stream = new MemoryStream(byteArray);

一旦我有了流,我想更新数据库表。我该怎么做?

谢谢

4

1 回答 1

3

WiX 附带的dtf.chm文档包含以下有关如何更新二进制表的示例:

Database db = null;
View view = null;
Record rec = null;
try
{
    db = new Database("product.msi", DatabaseOpenMode.Direct);
    view = db.OpenView("UPDATE `Binary` SET `Data` = ? WHERE `Name` = '{0}'", binName))
    rec = new Record(1);
    rec.SetStream(1, binFile);
    view.Execute(rec);
    db.Commit();
}
finally
{
    if (rec != null) rec.Close();
    if (view != null) view.Close();
    if (db != null) db.Close();
}
于 2013-01-28T13:47:53.997 回答