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...

What is sequence of code in retrieving data from database ?

Answer Posted / senthil kumar

if you use sql server
SqlConnection con = new SqlConnection();
con.ConnectionString ="Data Source=servername;Initial
Catalog=databasename;";
con.Open();
String sql;
sql ="select * from tbl_tablename";
SqlCommand cmd = new SqlCommand(sql,con);
SqlDataReader reader;
reader = cmd.ExecuteReader();
while(reader.Read)
{
Console.WriteLine("Field1:"+read.GetString(0));
Console.WriteLine("Field1:"+read.GetString(1));
Console.WriteLine("Field1:"+read.GetValue(2));
}
con.Close();
}

Is This Answer Correct ?    9 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define data access layer?

904


What is ado full form?

966


What is ado.net connection?

911


What is ado.net objects?

910


What is difference between ado and other data object?

865


Which name space is used to get assembly details?

923


What is the purpose of using adodb?

904


differance between ADO vs ADO.Net?

996


How can we load multiple tables in to dataset?

1033


What is an example of ordinal data?

1050


What are all components of ADO.Net data provider?

1007


How to read data with the sqldatareader ?

924


What are the essential features of ado.net?

899


What is a non query?

889


What is ado.net and its architecture?

1076