How to use c sharp properties and after get value save in sql database.

Recommended Answers

All 4 Replies


Do you want to create a property in C#, for example a FirstName string property, set the property and store the value of that porperty in your database ?

yes ChrisHunter You understood . Now Please Tell Me How can i do this

 Private string _firstname;
    public string FirstName
    get{ return _firstname;} set {_firstname = Value}


how can i store this value in my database

Just use the property name in your SQL statement. Might be different depending on what type of DB you're using but it should look something like this i think:

"INSERT INTO myTable (firstName) Values ('" + _firstname + "')";

I hope this helps at all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.