insert a image to the database(convert byte[] to binary)
来源:互联网 发布:奉贤网络电视台 编辑:程序博客网 时间:2024/05/17 23:46
byte[] data = null;
string sPath = "C://photoimage.jpg";
//Use FileInfo object to get file size.
FileInfo fInfo = new FileInfo(sPath);
long numBytes = fInfo.Length;
//Open FileStream to read file
FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);
//Use BinaryReader to read file stream into byte array.
BinaryReader br = new BinaryReader(fStream);
data = br.ReadBytes((int)numBytes);
//Read Image Bytes into a byte array
byte[] imageSampleData = data;
//Initialize SQL Server Connection
string str_db_err = string.Empty;
DataSet ds = new DataSet();
//string str = Encoding.Unicode.GetString(imageSampleData);
string str = BitConverter.ToString(imageSampleData);
str = "0x" + str.Replace("-","");
//string querystr = "INSERT INTO ClearanceDB.dbo.Perso (PhotoImage,PhotoImageFormat) values(imageSampleData,'jpeg')";
string querystr = "update table1 SET PhotoImage = " + str + " WHERE ID = 1";
ds = MySQLHelper.ExecuteStoredProcedure(querystr,null);
str_db_err = MySQLHelper.DBError;
// gets database data about job details and sets it for display
if (str_db_err == "")
{
}
- insert a image to the database(convert byte[] to binary)
- insert a image to the database. (convert byte[] to varbinary)
- image to DataBase and show the image
- img2html:Convert a image to HTML
- Convert pdf to image
- Convert a byte array to a Hex string
- convert a byte array to a hexadecimal string
- convert a hexadecimal string to a byte string
- convert a number to the cash equivalent
- convert decimal to binary
- Convert byte array to char* in a clr wrapper
- convert a 32-bit database to 64-bit
- convert from to (byte [] array)
- convert byte[4] to int32
- Q4.3 Convert a sorted array to a binary tree
- Convert a Ternary expression to a Binary tree structure
- How to Convert a 32-bit Database to 64-bit Database on Linux (remove olap)
- How to Convert a 32bit Database to 64bit Database on Linux
- Android学习3——注册
- 不同窗体的控件传值问题
- android 图片平铺实现
- 在sqlserver中操作image、varbinary
- linux 终端快捷键
- insert a image to the database(convert byte[] to binary)
- AMF协议的数据封装和文件解析
- RabbitMQ-C客户端使用说明
- 先思再行 闭着眼睛编程
- C#向SqlServer varbinary类型插数据
- sqlite 数据类型 全面
- MVC实现增删查改
- Oracle RAC 日志 存放路径总结
- IoAllocateMd函数参数length限制