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

Is entity framework better than ado.net?

1018


Why do we need ado.net?

969


What is the difference between a datareader and a dataset?

1043


What is the difference between oledb sql server and oledbdotnet provider?

1014


What is bubbled event?

976


What are all the different methods under sqlcommand?

989


What is connected architecture in ado.net?

1074


What is data access pattern?

946


What is dataset object? Explain the various objects in dataset.

1052


What are the advantages using ado.net?

1039


Explain the advantage of ADO.Net?

991


Explain the difference between ado and ado.net?

941


What are the important features of ado.net 2.0?

1076


Explain executenonquery?

1140


Which name space is used to get assembly details?

994