private void Submit_Click(object sender, EventArgs e)
{
byte[] picbyte = System.IO.File.ReadAllBytes(textBox.Text);
try
{
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\PIS(ACU).mdb;";
Con = new OleDbConnection(@constr);
Con.Open();
Com = new OleDbCommand();
Com.Connection = Con;
Com.CommandText = "INSERT INTO Pics(Patient_Id,ImageDate,Photo)VALUES(" + txtPatientId.Text + ",'" + txtImageDate.Value.ToString("yyyy/MM/dd HH:mm:ss") + "', @Photo)";
OleDbParameter picParam = Com.Parameters.Add("@Photo", SqlDbType.Binary);
picParam.Value = picbyte.ToArray();
picParam.Size = picbyte.ToArray().Length;
Com.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
Con.Close();
MessageBox.Show("Image Uploaded Successfully", "PIS System");
DiseaseRecord D = new DiseaseRecord();
D.Show();
this.Close();
}
}
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
fd.InitialDirectory = "c:\\";
if (fd.ShowDialog() == DialogResult.OK)
{
textBox.Text = fd.FileName.ToString();
pictureBox.ImageLocation = textBox.Text;
}
Console.ReadLine();
}