ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  ADO.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
Sequence to connect and retrieve data from database useig
dataset ?
 Question Submitted By :: Deepa
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Sequence to connect and retrieve data from database useig dataset ?
Answer
# 1
public SqlConnection con = new SqlConnection("server=anwar; 
uid=sa; pwd=s;database=Employee;");
 public SqlCommand cmd;
 public SqlDataAdapter da;
  public   DataSet ds;
     
cmd = new SqlCommand("select * from empdetails", con);
       
        da = new SqlDataAdapter(cmd);
        ds = new DataSet();
        da.Fill(ds, "empdetails");
        foreach(DataRow dr in ds.Tables["empdetails"].Rows)
        {
            txtempname.Text = dr["name"].ToString();
            txtdob.Text = dr["dob"].ToString();
            txtstreetname.Text = dr["street"].ToString();
        } // foreach
 
Is This Answer Correct ?    5 Yes 2 No
A.anwar Sadat
 
  Re: Sequence to connect and retrieve data from database useig dataset ?
Answer
# 2
We r talking about vb.net not c# codding
system.data
system.data.sqlclient

dim con,s as string
con="Server=servername;database=name;uid=sa;pwd=;"
s="Select * from tablename"
dim ad as new sqldataadapter(s,con)
dim ds as dataset
ad.fill(ds)
dim dv as dataview= new dataview(ds.tables("tablename"))
dv.sort="Name desc"
listbox.datasource=ds
listbox.displayMember="Name"&"Age"&"sex"...
 
it will work fine thanx!
 
Is This Answer Correct ?    0 Yes 1 No
Ashokdahiya
 
 
 
  Re: Sequence to connect and retrieve data from database useig dataset ?
Answer
# 3
The sequence is
Step 1: Create a Connection Object with Connection String
         Eg: <Provider**>Connection ActiveConnection = new 
<Provider**>Connection(<ConnectionString>)

Step 2: Create a Command Object with Command Text and the 
created Connection Object

       Eg: <Provider**>Command Qry = new <Provider**>Command
(<Command Text>,        ActiveConnection)

Step 3: Set the command Type for the created Command
           Eg: Qry.CommandType = CommandType.Text

Step 4: Create Data Adapter with the created Command
          Eg: <Provider**>DataAdapter da = new 
<Provider**>DataAdapter(Qry*);

Step 5: Create a DataSet Object.
          Eg: DataSet ds = new DataSet();

Step 6: populate the dataset by calling the fill method of 
Data adaper against the Data set object
           Eg: da.Fill(ds); 

__________________________________________________________
*Qry contains a select query (or) Stored Procedure Name 
containing a Select Query

** If the provider is SQL server then the Connection type 
is SQLConnection, Command type is SQLCommand and Data 
adapter type is SQLDataAdapter.
 
Is This Answer Correct ?    1 Yes 1 No
Vaidyanathan R.
 

 
 
 
Other ADO.NET Interview Questions
 
  Question Asked @ Answers
 
what is clustered index?why is it created? Microsoft3
What provider ADO.net use by default? Accenture5
How To Update A Column In A DataGrid Using C#.NET? I am getting InvalidCastException as (Specified cast is not valid) while updating 2nd column in a datagrid? Id,firstname,lastname are the three columns of my datagrid respectively. I wanted to edit the second column(lastname) and update it. I did the following code in DataGrid's updatecommand(),but failed to update ! Int varid=(int)DataGrid1.DataKeys[e.Item.ItemIndex]; TextBox lnm=(TextBox)e.Item.Cells[2].Controls[0]; string str=lnm.Text ; SqlCommand cmd=new SqlCommand("update customer set lastname='" + str + "' where id=" + varid + "",con); cmd.ExecuteNonQuery(); DataGrid1.EditItemIndex=- 1; DataGrid1.DataBind(); Mind-Tree2
ADO and ADO.NET differences ? Microsoft2
If a table contains 20000 records . In a page at each time 100 records to be displayed. What are the steps u will take to improve performance? will you use dataset or datareader?  6
what is the criteria of selection in sbi interview? SBI1
what is connection pooling ? Vertex3
what is the syntax code to oledb to connect oracle IBM5
How to you declare connection strings and how to you make use of web.config ? MMTS2
how would i implement dropdownlist in gridview using c#  2
What are the attirbutes of DataSet? IBM5
What is dataset and tell about its features. What are equivalent methods of previous, next etc. Of ADO in ADO.NET ? Digital-GlobalSoft1
what are the differences between dataset and datareader? Choice-Solutions2
Being fresher How would i answer to the question that what is your salary exception?  3
How to generate XML from a dataset and vice versa?  2
what is a dataview?why is it used for? Choice-Solutions3
what is the syntax code for oldb to connect oracle IBM2
Execute nonquery returns no. of afected rows.So if my stored procedure hav lot of select stmnt, delete stmnt, insert stmnt..then what does execute nonquery returns in this case?  1
Difference between OLEDB Provider and SqlClient ?  2
what is bubbled event can u pls explain Wipro3
 
For more ADO.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com