Académique Documents
Professionnel Documents
Culture Documents
You may want to try: Ado Dot Net Interview Question Part 1 SOA Interview questions Part 1
7,956,497 members and growing! (30,948 online) Email Password Sign in Join
Home
Articles
Learning Zones
Features
Help!
The Lounge
See Also
More like this More by this author 2.88 (18 votes) 8
Sponsored Links
ADO.NET
(B) How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures? (B) How c an we forc e the connection object to close after my data reader is c losed? (B) I want to forc e the data reader to return only sc hema of the data store rather than data. (B) How c an we fine-tune the c ommand objec t when we are expecting a single row? (B)What are the various methods provided by the dataset objec t to generate XML? (B) How c an we save all data from dataset? (B) How c an we check that some changes have been made to dataset sinc e it was loaded? (B) How c an we add/remove row is in Data Table object of Dataset? (B) What is basic use of Data View? (B) What is the differenc e between Dataset and Data Reader ? (B) How c an we load multiple tables in a Dataset? (B) How c an we add relation between tables in a Dataset? (B) What is the use of Command Builder? (B) Whats difference between Optimistic and Pessimistic locking ? (A) How many ways are there to implement locking in ADO.NET? (A)How can we perform transac tions in .NET? (I) What is difference between Dataset? Clone and Dataset. Copy? (A) Can you explain the difference between an ADO.NET Dataset and an ADO Record set? (A) Explain in detail the fundamental of connection pooling? (A)What is Maximum Pool Size in ADO.NET Connec tion String? (A)How to enable and disable connec tion pooling? (I) What extra features does ADO.Net 2.0 have ?
See Also...
Announcements
Introduction
In this section we will touch base on one of important concepts in ADO.Net. You can download my .NET Interview Question PDF from http://www.questpond.com/SampleDotNetInterviewQuestionBook.zip .
I have also put all these design patterns in a video format and uploaded on http://www.questpond.com/FreeDesign1.htm . You can visit http://www.questpond.com and download the complete architecture interview questions PDF which covers SOA , UML , Design patterns , Togaf , OOPs etc. You can download the software architecture interview questions PDF Download Software Architecture Interview Questions Previous parts of my Interview questions series for Architects Part 1 - SoftArchInter1.aspx Part 2 - SoftArch2.aspx Part 3 - SoftArch3.aspx Part 4 - SoftArch4.aspx UML interview questions part 1 SoftArch5.aspx Happy job hunting......
(B) How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
ADO.NET provides the SqlCommand object, which provides the functionality of exec uting stored procedures. Note :- Sample code is provided in folder WindowsSqlClientCommand. There are two stored procedures created in same database Employees which was created for the previous question. CREATE PROCEDURE SelectByEmployee @FirstName nvarchar(200) AS Selec t FirstName from Employees where FirstName like @FirstName + '%' CREATE PROCEDURE SelectEmployee AS Selec t FirstName from Employees If txtEmployeeName.Text.Length = 0 Then objCommand = New SqlCommand(SelectEmployee) Else objCommand = New SqlCommand(SelectByEmployee) objCommand.Parameters.Add(@FirstName, Data.SqlDbType.NVarChar, 200) objCommand.Parameters.Item(@FirstName).Value = txtEmployeeName.Text.Trim() End If In the above sample, not much has been c hanged only that the SQL is moved to the stored proc edures. There are two stored procedures one is Select Employee which selects all the employees and the other is Selec tByEmployee whic h returns employee name starting with a specific c haracter. As you can see to provide parameters to the stored procedures, we are using the parameter object of the command object. In such question interviewer expec ts two simple answers one is that we use command object to exec ute stored proc edures and the parameter objec t to provide parameter to the stored procedure. Above sample is provided only for getting the actual feel of it. Be short be nice and get a job.
(B) How can we force the connection object to close after my data reader is closed?
Command method Exec ute reader takes a parameter c alled as Command Behavior where in we can spec ify saying close c onnec tion automatically after the Data reader is c lose. PobjDataReader = pobjCommand.ExecuteReader (CommandBehavior.CloseConnection)
(B) I want to force the data reader to return only schema of the data store rather than data.
PobjDataReader = pobjCommand.Exec uteReader (CommandBehavior.Sc hemaOnly)
(B) How can we fine-tune the command object when we are expecting a single row?
Again, CommandBehaviour enumeration provides two values Single Result and Single Row. If you are expecting a single value then pass CommandBehaviour.SingleResult and the query is optimized ac cordingly, if you are expecting single row then pass CommandBehaviour.SingleRow and query is optimized according to single row. (B) Whic h is the best place to store c onnec tion string in .NET projects? Config files are the best plac es to store connection strings. If it is a web-based application Web.c onfig file will be used and if it is a windows application App.config files will be used.
(B) What are the steps involved to fill a dataset? Twist: - How c an we use data adapter to fill a dataset? Sample code is provided in WindowsDataSetSample folder in CD.LoadData has all the implementation of c onnec ting and loading to dataset. This dataset is finally bind to a List Box. Below is the sample c ode. Private Sub LoadData() Dim strConnectionString As String strConnec tionString = AppSettings.Item(ConnectionString) Dim objConn As New SqlConnection(strConnectionString) objConn.Open() Dim objCommand As New SqlCommand(Select FirstName from Employees) objCommand.Connec tion = objConn Dim objDataAdapter As New SqlDataAdapter() objDataAdapter.SelectCommand = objCommand Dim objDataSet As New DataSet End Sub In such type of questions interviewer is looking from practical angle, that have you worked with dataset and datadapters. Let me try to explain the above code first and then we move to what steps should be told during interview. Dim objConn As New SqlConnection(strConnectionString) objConn.Open() First step is to open the connection. Again, note the connection string is loaded from config file. Dim objCommand As New SqlCommand(Select FirstName from Employees) objCommand.Connec tion = objConn Second step is to c reate a c ommand object with appropriate SQL and set the c onnec tion objec t to this command. Dim objDataAdapter As New SqlDataAdapter() objDataAdapter.SelectCommand = objCommand Third steps is to create the Adapter objec t and pass the c ommand objec t to the adapter object. objDataAdapter.Fill(objDataSet) Fourth step is to load the dataset using the Fill method of the data adapter. lstData.DataSource = objDataSet.Tables(0).DefaultView lstData.DisplayMember = FirstName lstData.ValueMember = FirstName Fifth step is to bind to the loaded dataset with the GUI. At this moment sample has list box as the UI. Binding of the UI is done by using Default View of the dataset. Just to revise every dataset has tables and every table has views. In this sample, we have only loaded one table i.e. Employees table so we are referring that with an index of zero. Just say all the five steps during interview and you will see the smile on the interviewers face and appointment letter in your hand.
(B)What are the various methods provided by the dataset object to generate XML?
Note:- XML is one of the most important leap between c lassic ADO and ADO.NET. So this question is normally asked more generally how c an we convert any data to XML format. Best answer is convert in to dataset and use the below methods. ReadXML Reads a XML document in to Dataset. GetXML This is a function, which returns the string containing XML doc ument. Writexml This writes a XML data to disk.
(B) How can we check that some changes have been made to dataset since it was loaded?
Twist: - How c an we cancel all c hanges done in dataset? Twist: - How do we get values, whic h are changed, in a dataset? For tracking down c hanges, Dataset has two methods, which comes as rescue Get Changes and Has Changes. Get Changes Returns dataset, whic h are c hanged since it, was loaded, or sinc e Ac cept c hanges was executed. Has Changes Or abandon all c hanges sinc e the dataset was loaded use Reject Changes This property indicates that has any changes been made since the dataset was loaded or ac cept c hanges method was executed. Note:- One of the most misunderstood things about these properties is that it trac ks the c hanges of ac tual database. That is a fundamental mistake; ac tually the c hanges are related to only c hanges with dataset and have nothing to with c hanges happening in actual database. As dataset are disconnected and do not know anything about the changes happening in actual database.
Begin a transaction using the Begin Transac tion method of the c onnec tion objec t. This method provides us with a transaction object that we will use later to commit or rollback the transaction. Note that changes c aused by any queries exec uted before c alling the Begin Transac tion method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above mentioned transac tion objec t. Execute the SQL commands using the c ommand object. We may use oneormorecommand objects for this purpose, as long as the Transac tion property of all the objec ts is set to a valid transaction object. Commit or roll back the transaction using the Commit or Rollback method of the transac tion objec t. Close the database c onnec tion.
(A) Can you explain the difference between an ADO.NET Dataset and an ADO Record set?
There two main basic differenc es between record set and dataset: With dataset you an retrieve data from two databases like orac le and sql server and merge them in one dataset , with rec ord set this is not possible All representation of Dataset is using XML while record set uses COM. Record set cannot be transmitted on HTTP while Dataset can be.
Figure 9.5: - Connection Pooling action. Let us try to explain the same pic torially. In the above figure, you can see there are three requests Request1, Request2, and Request3. Request1 and Request3 have same c onnec tion string so no new c onnec tion objec t is created for Request3 as the c onnection string is same. They share the same object ConObject1. However, new objec t ConObjec t2 is created for Request2 as the c onnec tion string is different. Note: - The difference between the c onnec tion string is that one has User id=sa and other has User id=Testing.
License
This article, along with any associated sourc e c ode and files, is lic ensed under The Code Project Open License (CPOL)
Article Top
Msgs 1 to 8 of 8 (Total in Forum: 8)Refresh good one Very helpfull I wouldnt hire you Re: I wouldnt hire you Re: I wouldnt hire you Thanks for sharing good help... A useless piece of meat on earth! Last Visit: 19:00 31 Dec '99 General News Last Update: 7:07 17 Jul '11 Suggestion Question
Use C trl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, C trl+PgUp/PgDown to switch pages.
P ermalink | A dvertis e | P rivac y | M obile | Web0 4 | 2 .3 .1 1 0 7 1 4 .3 L ayout: fixed | fluid A rtic le C opyright 2 0 0 8 by Shivpras ad koirala E verything els e C opyright C odeP rojec t, 19 9 9 - 20 1 1 T erms of U s e