如何插入二进制图像 [英] How to insert binary image
本文介绍了如何插入二进制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我在gridview中有二进制图像我想将图像二进制值插入数据库。
( 插入表(名称,HOFImage)值(' + g1.Cells [ 0 ]。文本+ ',' + Convert.ToByte(g1 .Cells [ 1 ]。文本)+ ') ,con);
给出错误'输入字符串格式不正确'。
我怎么办请帮忙?
解决方案
首先,这个实现容易受到 SQL注入 [ ^ ]
我建议使用参数化查询 [ ^ ]或存储过程 [ ^ 一>]。
Hello,
I have binary image in gridview i want to insert image binary value into database .
("insert into table(Name,HOFImage) values ('" + g1.Cells[0].Text + "','" + Convert.ToByte(g1.Cells[1].Text) + "')", con);
it is giving error 'Input string was not in a correct format'.
how i do please help ??
解决方案
First of all, this implementation is susceptible to SQL Injection[^]
I would suggest to use Parameterized Queries [^] or a Stored Procedure[^].
这篇关于如何插入二进制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文