Click here to Skip to main content
15,917,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have binary image in gridview i want to insert image binary value into database .
C#
("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 ??
Posted
Updated 14-Nov-14 22:30pm
v2
Comments
Member 11014751 15-Nov-14 3:24am    
("insert into table(Name,HOFImage) values ('" + g1.Cells[0].Text + "','" + Convert.ToByte(g1.Cells[1].Text) + "')", con);

i am doing like this
George Jonsson 15-Nov-14 4:33am    
Use the 'Improve question' button instead of adding info here.
Member 11014751 15-Nov-14 3:24am    
it is giving error Input string was not in a correct format.
George Jonsson 15-Nov-14 4:34am    
What is the type of data you have in g1.Cells[1] ?
MJ2014 15-Nov-14 5:36am    
pls check in your database. field type should be LONGBINARY then only your database will accepts images.

1 solution

First of all, this implementation is susceptible to SQL Injection[^]

I would suggest to use Parameterized Queries [^] or a Stored Procedure[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900