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 does console readline do?

867


What is the default value of datetime in c#?

969


Can we change static value in c#?

1048


Write a short note on interface?

987


What is a console?

922


What is the difference between yield and return?

880


How do I do a case-insensitive string comparison?

1048


What is a Managed Code??

1018


What is var c#?

984


What is private class in c#?

925


What is the difference between dictionary and hashtable in c#?

902


What is an enumerator c#?

915


Define c# i/o classes?

919


How to override a function in c#?

1002


Why c# is called c sharp?

885