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

How to implement an object pool in c#.net.

1101


What are the 3 types of comments in c#?

994


Write a short note on interface?

1044


What is local function?

986


What does an indexer do?

952


Explain the difference between a struct and a class?

997


What are handlers in c#?

998


What is the wildcard character in sql?

1111


What is the difference between virtual and override in c#?

1132


What does out mean c#?

997


Where do we set the min and max pool size for connection pooling?

1017


what is the purpose of using statement in c#

1054


What is data binding c#?

997


What is static class in C#?

1068


Explain about multithreading?

1090