byte[] image=二进制图片信息;
SqlConnection conn = new SqlConnection(连接字符串);
string sql =至少带image类型参数的SQL语句(一般为Insert或Update,例如:"Insert into Images(imageid,imagecontent) select 8,@imagecontent"或"update images set imagecontent=@imagecontent where imageid=8") ;
SqlCommand com = new SqlCommand();
SqlParameter par = new SqlParameter("@imgcontent",SqlDbType.Image);
myCommand.Connection = con;
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = sql;
par.Value = image;
com.Parameters.Add(par);
con.Open();
com.ExecuteNonQuery();
con.Close();
注:1.存储过程中一般不能把image和text作为传入参数类型,当然可以通过自定义扩展等方法使其可以传入这类参数;
2.也可使用微软企业库等进行image数据的插入和更新等操作。
3.对于读取image类型,几乎没有限制。