Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table with column name Image and datatype image, when i choose filename to save into database, its says that the string doesnot match the datatype. the path of the selected file is like C:\\Users\\mydocument\\pic something like that......so how can i save file , please provide with the code
bishnu karki
Posted

Thta is because image is for storing a large quantity of binary data: the Image data itself.
If you want to store filename, then either convert it to a byte array:
C#
string s = " C:\\Users\\mydocument\\pic";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(s);

or change the datatype in your database to a string type: NVARCHAR for example.
 
Share this answer
 
Rather than storing the image itself in the database, try storing just the path of the image and then when you want to use the image in your app, you can just retrieve the path and load it from the your disk. Its a much simpler approach with no extra conversions and manipulations to take care of.
 
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