FileStream fs = File.OpenRead(fullname);
byte[] content = new byte[fs.Length];
fs.Read(content, 0, content.Length);
fs.Close();
string connStr = "workstation id=localhost;Integrated Security=SSPI;database=djBook";
string insertCmd =
"Insert Into 图库(编号,名称,图片)Values(@编号,@名称,@图片)";
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand cmd = new SqlCommand(insertCmd, conn);
cmd.Parameters.Add("@编号", SqlDbType.VarChar);
cmd.Parameters.Add("@名称", SqlDbType.VarChar);
cmd.Parameters.Add("@图片", SqlDbType.VarChar);
cmd.Parameters["@编号"].Value = strToolNum;
cmd.Parameters["@名称"].Value = strToolName;
cmd.Parameters["@图片"].Value = content;
cmd.ExecuteNonQuery();
MessageBox.Show("图片成功保存!");
数据库中图片的类型是image 就行了