Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to binding image in sql, I need get and set property value of image

for ex:

C#
private string _Username;

public string Username
{
get {return _username;}
set{_username=value;}


I want syntax for image.
Posted
Updated 26-Mar-15 23:09pm
v2

Just the way you're giving string type for your username member, you will be giving a specific data type to your Image member.

It depends on your framework of application, to choose which object type for your data. Bitmap[^], Image[^], byte[][^] and all other such data types can fulfill your need of defining an Image object. You can then -- when required -- convert them into graphics object to represent your data.

In SQL, image field is also a field that contains arrays of byte. Which is given the value of byte arrays of the image (actually a file) and then can be retrieved as byte arrays and converted to files and so on.

I would also tip you, to not create another member while using getters and setters. Use it like,

C#
public string Username { get; set; }


This would have the same functionality of retrieving the Username and setting the Username and so on.
 
Share this answer
 
Comments
Gokulprasad05 27-Mar-15 5:27am    
i didnt want user name i want username replace image i want to bind the image in sql got it
Afzaal Ahmad Zeeshan 27-Mar-15 5:29am    
Yes, I know you presented Username as an example but I thought I might give you a tip about that too. Now in this one, replace Username with Image and string with the type of object you think would be better.
Gokulprasad05 27-Mar-15 5:34am    
respected sir i didn't understand plz send syntax for get and set property for image
Refer the below link...
Here the image is converted to byte array and saved in DB and retrieving those byte array.


http://www.c-sharpcorner.com/UploadFile/0f100d/storing-and-retrieving-image-from-sql-server-database-in-wpf/[^]

you can have a property like this
public BitmapImage bitmapImageSource { get; set; }
 
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