In winform:
// Storage
Private void MemoryImage ()
{
StringSQL= "";
// String conn = "Provider = SQLNCLI; DaTa Source = 192.168.0.9, 1433; Database = WebDown; UID = sa; PWD = 111122 ;";
Stream MS;
Byte [] picbyte;
OpenFileDialog fdSelectPic = new OpenFileDialog ();
If (ofdSelectPic. ShowDialog () = DialogResult. OK)
{
If (MS = ofdSelectPic. OpenFile ())! = Null)
{
Picbyte = new byte [ms. Length];
Ms. Position = 0;
Ms. Read (picbyte, 0, Convert. ToInt32 (ms. Length ));
// ConnectionDatabase
SqlConnection conn = new SqlConnection ();
Conn. ConnectionString = "DaTa Source = 192.168.0.9, 1433; Database = WebDown; UID = sa; PWD = 111122 ;";
SQL = "Insert into LibraryCover (Cover) values (@ UpdateImage )";
SqlCommand cmd = new SqlCommand (SQL, conn );
Cmd. Parameters. Add ("@ UpdateImage", SqlDbType. VarBinary );
Cmd. Parameters ["@ UpdateImage"]. Value = picbyte;
Conn. Open ();
Cmd. ExecuteNonQuery ();
Conn. Close ();
Ms. Close ();
}
}
MessageBox. Show ("finished! ");
}
// Read
Private void ShowImage ()
{
String SQL = "";
& Nb