GeekInterview.com
Series: Subject: Topic:
Question: 32 of 169

How can retrieve the data from database? what is cell in dot frameworks?

Asked by: Interview Candidate | Asked on: Apr 18th, 2007
Showing Answers 1 - 3 of 3 Answers
prabanand2000

Answered On : Feb 9th, 2009

View all answers by prabanand2000

We can retrieve data from database using ADO.NET we can use connection string in which data reader data adapter can be used. Data set are used for retrieve bulk of data.
We can also use data binder which binds the data.
The cell in .Net is used for changing events.

  
Login to rate this answer.
mike19

Answered On : Sep 22nd, 2011

View all answers by mike19

Copy/Paste the code and study it. For me it works.

Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data.SqlClient;
  5. using System.Data;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             SqlConnection con = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=YourDatabase;Integrated Security=True;");
  14.             try
  15.             {
  16.             con.Open();
  17.             SqlCommand cmd = new SqlCommand("SELECT * FROM Table1", con);
  18.             SqlDataReader reader = cmd.ExecuteReader();
  19.                 while(reader.Read())
  20.                 {
  21.                     Console.Write(reader[0]);
  22.                     Console.WriteLine(reader[1]);
  23.                 }
  24.        
  25.            
  26.             }catch(Exception e)
  27.             {
  28.                 Console.WriteLine(e);
  29.             }
  30.            
  31.             }
  32.     }
  33. }
  34.  

  
Login to rate this answer.
vikramreddy

Answered On : Feb 15th, 2012

FOR CONNECT

1.establish the connection between the database

2.send the request(execute the command)

3.get the data form data base

4.close connection

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.