110,577
社区成员
发帖
与我相关
我的任务
分享
SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=;database=s");
conn.Open();
string strSql = "select file from ttt ";
SqlCommand cmd = new SqlCommand(strSql, conn);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
MemoryStream ms = new MemoryStream((byte[])sdr[0]);
Stream ms;
byte[] _byte;
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
string f = ofd.FileName;
ms = ofd.OpenFile();
_byte = new byte[ms.Length];
ms.Position = 0;
ms.Read(_byte, 0, Convert.ToInt32(ms.Length));
SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=;database=s");
conn.Open();
string sqlstring = "insert into ttt(file) values(@pdf)";
SqlCommand cmd = new SqlCommand(sqlstring, conn);
cmd.Parameters.Add("@pdf", SqlDbType.Image, _byte.Length).Value = _byte;
Stream ms;
byte[] _byte;
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
string f = ofd.FileName;
ms = ofd.OpenFile();
_byte = new byte[ms.Length];
ms.Position = 0;
ms.Read(_byte, 0, Convert.ToInt32(ms.Length));
SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=;database=s");
conn.Open();
string sqlstring = "insert into ttt(file) values(@pdf)";
SqlCommand cmd = new SqlCommand(sqlstring, conn);
cmd.Parameters.Add("@pdf", SqlDbType.Image, _byte.Length).Value = picbyte;
FileStream fs = new FileStream(path, FileMode.Open);
byte[] b=new byte[fs.Length];
fs.Read(b, 0, fs.Length);
fs.Close();
FileStream _fs = new FileStream(path, FileAccess.Write);
_fs.Write(b, 0, b.Length);
_fs.Close();