RSS Forums RSS
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting

Retrieve Information from Database & Display into ASP.NET Web Controls Textbox

Join Date: Jun 2005
Posts: 50
Reputation: Naters_uk is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Naters_uk Naters_uk is offline Offline
Junior Poster in Training

Re: Retrieve Information from Database & Display into ASP.NET Web Controls Textbox

  #3  
Sep 8th, 2005
Hi Aish,

I do not understand what is this line of code is doing except a rough guess that it is trying to read the column MemberUserName. Would you mind explaining it to me? In addition, i am writing this code using ASP.NET with VB. Would you mind tuning this part of the codes that i have quoted into ASP.NET with VB as i am having a hard time trying to fix it into that. :o

//if it is a text box
txtbox_user.Text=reader.IsDBNull(reader.GetOrdinal("MemberUserName"))? null: reader["MemberUserName"].ToString();
//if it is a dropdown put defalut value 0 or 1, what ever value you use.
DropDown_Children.SelectedValue=Convert.ToString(reader.IsDBNull(reader.GetOrdinal("NumofChildren")) ? (int)0 : (int)reader["NumofChildren"]);





Originally Posted by aish
you can use data reader for this,

command = new SqlCommand("SELECT * FROM Member",sqlConnection );
command.CommandType = CommandType.StoredProcedure;
try
{
sqlConnection.Open();
reader=command.ExecuteReader();
while (reader.Read())
{
//if it is a text box
txtbox_user.Text=reader.IsDBNull(reader.GetOrdinal("MemberUserName"))? null: reader["MemberUserName"].ToString();
//if it is a dropdown put defalut value 0 or 1, what ever value you use.
DropDown_Children.SelectedValue=Convert.ToString(reader.IsDBNull(reader.GetOrdinal("NumofChildren")) ? (int)0 : (int)reader["NumofChildren"]);

}
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
reader.Close();
sqlConnection.Close();
}
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 7:47 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC