Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

C# Code for How to set readonly property to Id(database)
value?

Answer Posted / deepak ray

Just retrieve the id from database using reader or dataset
and store the id in a string.
and
set the string in a public readonly property like this.


string _UserId;
public string UserId
{ get { return _UserId; } }

SqlDataReader dr = null;
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
_UserId = dr["UserId"].ToString();
}
dr.Close();
dr.Dispose();

Is This Answer Correct ?    10 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is writeline in c#?

816


What is bit in c#?

926


What is helper method in c#?

869


Can arraylist hold primitive types?

960


Can a child class call the constructor of a base class?

984


How to Install uninstall assemblies into GAC?

889


What is a partial class. Give an example?

913


What is an interface class? Give one example of it

850


Why can't we use a static class instead of singleton?

821


What is ioc containers c#?

826


What is array formula?

850


Explain circular reference in c#?

888


how to sort an array in c#

935


Explain the difference between access specifier and access modifier in c#?

915


Why do we use interface in c#?

928