将Imagedata导入mysql

将Imagedata导入mysql

本文介绍了将Imagedata导入mysql DB - Parallelitätsverletzungbeim更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请帮忙。我得到一个mysql - 错误:parallelitätsverletzungbeim更新与以下代码 - 我找不到错误。



编码:



Hi,
Please help. I get an mysql - error: parallelitätsverletzung beim update with the following code - I can'nt find the bug.

Coding:

private byte[] convertPic(string fn)
{
    FileStream fs = new FileStream(fn, FileMode.Open, FileAccess.Read);
    byte[] data = new byte[fs.Length];
    fs.Read(data, 0, Convert.ToInt32(fs.Length));
    fs.Close();
    return data;
}

private void btn_Pic_Click(object sender, EventArgs e)
{
    panel1.Visible = true;
    MySqlDataAdapter dbpic = new MySqlDataAdapter("select * from pat_picture order by Patient_ID", DBC);
    DataSet spic = new DataSet();
    dbpic.Fill(spic);
    int cnt = 0;
    int err = 0;
    foreach (DataRow rp in spic.Tables[0].Rows)
    {
        MySqlCommandBuilder cmb = new MySqlCommandBuilder(dbpic);
        try
        {
            rp["BildDaten"] = convertPic(@"D:\asys\Pictures\" + rp["Datei"].ToString().TrimEnd(' '));             // BildDaten = longblob
            cnt++;
        }
        catch
        {
            err++;
            continue;
        }
    }
    MySqlCommandBuilder cmbp = new MySqlCommandBuilder(DBBef);
    try
    {
        dbpic.UpdateCommand = cmbp.GetUpdateCommand();
        dbpic.Update(spic);
        MessageBox.Show("Konvertiert: " + cnt.ToString() + ", Fehlerhafte Sätze: " + err.ToString());
    }
    catch (Exception ep)
    {
        MessageBox.Show(ep.Message);
    }
}





提前谢谢

你的MiKr41



Thank you in advance
Your's MiKr41

推荐答案

这篇关于将Imagedata导入mysql DB - Parallelitätsverletzungbeim更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 00:10