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); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)