|
我写进的时候是用
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;
}
谁能写出读出图片来
我在这拜托了 |
|