|
When I write it, I use
private void button2_Click (object sender, System.EventArgs e)
{
try
{
byte [] photo = GetPhoto (@ "E:\Documents and Settings\wys\My Documents\15.jpg");
SqlConnection con = new SqlConnection ("server = .; uid = sa; pwd =; database = PJ;");
con.Open ();
SqlCommand com = new SqlCommand ("INSERT INTO TABLE1 (edd) Values ('" + photo + "')", con);
com.ExecuteNonQuery ();
con.Close ();
}
catch (Exception x)
{
MessageBox.Show (x.Message);
}
}
public static byte [] GetPhoto (string filePath)
{
FileStream fs = new FileStream (filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader (fs);
byte [] photo = br.ReadBytes ((int) fs.Length);
br.Close ();
fs.Close ();
return photo;
}
Who can write the read out picture
I beg you here |
|