This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Can We Connect To Microsoft Access, Foxpro, And Oracle Etc? |
|
Answer» Microsoft provides System.Data.OleDb namespace to communicate with databases like success , Oracle etc. In SHORT, any OLE DB-Compliant database can be connected using System.Data.OldDb namespace. Private Sub loadData() DIM strPath As String strPath = AppDomain.CurrentDomain.BaseDirectory Dim objOLEDBCon As New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0; Data Source =” & strPath & “Nwind.mdb”) Dim objOLEDBCommand As OleDbCommand Dim objOLEDBReader As OleDbDataReader Try objOLEDBCommand = New OleDbCommand(“SELECT FirstName from Employees”) objOLEDBCon.Open() objOLEDBCommand.Connection = objOLEDBCon objOLEDBReader = objOLEDBCommand.ExecuteReader() Do While objOLEDBReader.Read() lstNorthwinds.Items.Add(objOLEDBReader.GetString(0)) Loop Catch ex As Exception Throw ex Finally objOLEDBCon.Close() End Try End SubThe main heart is the “LOAD data ()” method which actually loads the data in list box. Microsoft provides System.Data.OleDb namespace to communicate with databases like success , Oracle etc. In short, any OLE DB-Compliant database can be connected using System.Data.OldDb namespace. The main heart is the “Load data ()” method which actually loads the data in list box. |
|
| 2. |
What Is The Use Of Connection Object? |
|
Answer» They are used to connect a data to a COMMAND object.
They are used to connect a data to a Command object. |
|
| 3. |
What Are Major Difference Between Classic Ado And Ado.net? |
|
Answer» Following are some MAJOR DIFFERENCES between both :-
Following are some major differences between both :- |
|
| 4. |
What Is The Namespace In Which .net Has The Data Functionality Class? |
|
Answer» Following are the namespaces provided by .NET for data management:- System. Data: System.Data.OleDB: System.Data.SqlClient: System.XML: Following are the namespaces provided by .NET for data management:- System. Data: System.Data.OleDB: System.Data.SqlClient: System.XML: |
|
| 5. |
How To Enable And Disable Connection Pooling? |
|
Answer» For .NET it is enabled by DEFAULT but if you want to just make sure SET Pooling=true in the connection string. To disable connection pooling set Pooling=false in connection string if it is an ADO.NET Connection. If it is an OLEDBConnection OBJECT set OLE DB Services=-4 in the connection string. For .NET it is enabled by default but if you want to just make sure set Pooling=true in the connection string. To disable connection pooling set Pooling=false in connection string if it is an ADO.NET Connection. If it is an OLEDBConnection object set OLE DB Services=-4 in the connection string. |
|
| 6. |
What Is Maximum Pool Size In Ado.net Connection String? |
|
Answer» Maximum pool size DECIDES the maximum number of connection objects to be pooled. If the maximum pool size is reached and there is no usable connection available the request is queued until connections are released back in to pool. So it’s ALWAYS a good habit to CALL the close or dispose method of the connection as SOON as you have finished work with the connection object. Maximum pool size decides the maximum number of connection objects to be pooled. If the maximum pool size is reached and there is no usable connection available the request is queued until connections are released back in to pool. So it’s always a good habit to call the close or dispose method of the connection as soon as you have finished work with the connection object. |
|
| 7. |
Can You Explain The Difference Between An Ado.net Dataset And An Ado Record Set? |
|
Answer» There two main BASIC differences between record set and dataset:-
There two main basic differences between record set and dataset:- |
|
| 8. |
How Can We Perform Transactions In .net? |
|
Answer» The most common sequence of steps that would be performed while developing a transactional application is as follows:
This method provides us with a transaction object that we will use later to commit or ROLLBACK the transaction. Note that changes caused by any queries executed before calling the Begin Transaction method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above MENTIONED transaction object.
The most common sequence of steps that would be performed while developing a transactional application is as follows: This method provides us with a transaction object that we will use later to commit or rollback the transaction. Note that changes caused by any queries executed before calling the Begin Transaction method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above mentioned transaction object. |
|
| 9. |
What Is The Use Of Command Builder? |
|
Answer» COMMAND Builder builds “Parameter” objects automatically. Below is a SIMPLE code, which uses command builder to load its parameter objects. Dim pobjCommandBuilder As NEW OleDbCommandBuilder(pobjDataAdapter) pobjCommandBuilder.DeriveParameters(pobjCommand) Be careful while using “Derive Parameters” method as it NEEDS an extra trip to the DATA store, which can be very inefficient Command Builder builds “Parameter” objects automatically. Below is a simple code, which uses command builder to load its parameter objects. Dim pobjCommandBuilder As New OleDbCommandBuilder(pobjDataAdapter) pobjCommandBuilder.DeriveParameters(pobjCommand) Be careful while using “Derive Parameters” method as it needs an extra trip to the Data store, which can be very inefficient |
|
| 10. |
How Can We Add Relation Between Tables In A Dataset? |
|
Answer» Answer :
Dim objRelation As DataRelation
objRelation=New Relations can be ADDED between “Data Table” objects using the “Data Relation” object. Above sample, CODE is trying to BUILD a RELATIONSHIP between “Customer” and “Addresses” “Data table” using “Customer Addresses” “Data Relation” object. Relations can be added between “Data Table” objects using the “Data Relation” object. Above sample, code is trying to build a relationship between “Customer” and “Addresses” “Data table” using “Customer Addresses” “Data Relation” object. |
|
| 11. |
How Can We Load Multiple Tables In A Dataset? |
|
Answer» Answer :
objCommand.CommandText = "Table1" Above is a sample code, which shows how to load MULTIPLE “Data Table” OBJECTS in one “Dataset” OBJECT. Sample code shows two tables “Table1” and “Table2” in object ObjDataSet. lstdata.DataSource = objDataSet.Tables("Table1").DefaultView In order to refer “Table1” Data Table, use Tables COLLECTION of Datasets and the Default view object will give you the necessary output. Above is a sample code, which shows how to load multiple “Data Table” objects in one “Dataset” object. Sample code shows two tables “Table1” and “Table2” in object ObjDataSet. lstdata.DataSource = objDataSet.Tables("Table1").DefaultView In order to refer “Table1” Data Table, use Tables collection of Datasets and the Default view object will give you the necessary output. |
|
| 12. |
What Is Basic Use Of "data View"? |
|
Answer» “Data View” represents a complete table or can be small section of rows depending on some criteria. It is best used for sorting and finding data with in “data table”. Data view has the following methods:- Find Find Row If we want to manipulate data of “Data Table” object create “Data View” (Using the “Default View” we can create “Data View” object) of the “Data Table” object and use the following FUNCTIONALITIES:- Add New Delete “Data View” represents a complete table or can be small section of rows depending on some criteria. It is best used for sorting and finding data with in “data table”. Data view has the following methods:- Find Find Row If we want to manipulate data of “Data Table” object create “Data View” (Using the “Default View” we can create “Data View” object) of the “Data Table” object and use the following functionalities:- Add New Delete |
|
| 13. |
How Can We Add/remove Row Is In "data Table" Object Of "dataset"? |
|
Answer» “Data table” PROVIDES “NewRow” method to add NEW row to “Data Table”. “Data Table” has “DataRowCollection” OBJECT that has all rows in a “Data Table” object. Following are the methods provided by “DataRowCollection” object:- Add REMOVE Remove At “Data table” provides “NewRow” method to add new row to “Data Table”. “Data Table” has “DataRowCollection” object that has all rows in a “Data Table” object. Following are the methods provided by “DataRowCollection” object:- Add Remove Remove At |
|
| 14. |
How Can We Save All Data From Dataset? |
|
Answer» DATASET has “Accept CHANGES” method, which commits all the changes SINCE last time “Accept changes” has been executed. Dataset has “Accept Changes” method, which commits all the changes since last time “Accept changes” has been executed. |
|
| 15. |
Which Is The Best Place To Store Connection String In .net Projects? |
|
Answer» CONFIG FILES are the best places to store CONNECTION strings. If it is a web-based application “Web.config” FILE will be used and if it is a windows application “App.config” files will be used. Config files are the best places to store connection strings. If it is a web-based application “Web.config” file will be used and if it is a windows application “App.config” files will be used. |
|
| 16. |
How Can We Fine-tune The Command Object When We Are Expecting A Single Row? |
|
Answer» 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 ACCORDINGLY, if you are expecting single row then pass “CommandBehaviour.SingleRow” and query is optimized according to 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 accordingly, if you are expecting single row then pass “CommandBehaviour.SingleRow” and query is optimized according to single row. |
|
| 17. |
I Want To Force The Data Reader To Return Only Schema Of The Data Store Rather Than Data? |
|
Answer» ANSWER : PobjDataReader = pobjCommand.ExecuteReader (CommandBehavior.SchemaOnly) |
|
| 18. |
How Can We Force The Connection Object To Close After My Data Reader Is Closed? |
|
Answer» COMMAND method EXECUTE reader takes a parameter called as Command BEHAVIOR where in we can SPECIFY saying close connection automatically after the Data reader is close. PobjDataReader = pobjCommand.ExecuteReader (CommandBehavior.CloseConnection)Command method Execute reader takes a parameter called as Command Behavior where in we can specify saying close connection automatically after the Data reader is close. |
|
| 19. |
What Is Difference Between Dataset Clone And Dataset Copy ? |
|
Answer» DATASET CLONE: - It only COPIES structure, does not copy data. Dataset copy: - Copies both structure and data. Dataset clone: - It only copies structure, does not copy data. Dataset copy: - Copies both structure and data. |
|
| 20. |
How Can We Perform Transactions In .net? |
|
Answer» The most COMMON sequence of steps that would be performed while DEVELOPING a transactional application is as follows:
This method provides us with a transaction object that we will use later to commit or rollback the transaction.Note that CHANGES caused by any queries executed before calling the Begin Transaction method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above mentioned transaction object. Execute the SQL COMMANDS using the command object. We may use one or more command objects for this purpose, as long as the Transaction property of all the objects is set to a valid transaction object. Commit or roll back the transaction using the Commit or Rollback method of the transaction object. CLOSE the database connection. The most common sequence of steps that would be performed while developing a transactional application is as follows: This method provides us with a transaction object that we will use later to commit or rollback the transaction.Note that changes caused by any queries executed before calling the Begin Transaction method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above mentioned transaction object. Execute the SQL commands using the command object. We may use one or more command objects for this purpose, as long as the Transaction property of all the objects is set to a valid transaction object. Commit or roll back the transaction using the Commit or Rollback method of the transaction object. Close the database connection. |
|
| 21. |
What's Difference Between "optimistic" And "pessimistic" Locking ? |
|
Answer» In pessimistic locking when user WANTS to update data it locks the record and till then no one can update data. Other user’s can only view the data when there is pessimistic locking. In optimistic locking MULTIPLE USERS can open the same record for updating, thus increase maximum concurrency. Record is only locked when updating the record. This is the most PREFERRED WAY of locking practically. Now a days browser based application is very common and having pessimistic locking is not a practical solution. In pessimistic locking when user wants to update data it locks the record and till then no one can update data. Other user’s can only view the data when there is pessimistic locking. In optimistic locking multiple users can open the same record for updating, thus increase maximum concurrency. Record is only locked when updating the record. This is the most preferred way of locking practically. Now a days browser based application is very common and having pessimistic locking is not a practical solution. |
|
| 22. |
What Is The Use Of Commandbuilder ? |
|
Answer» CommandBuilder builds “Parameter” objects automatically. Below is a simple code which uses commandbuilder to load its parameter objects. DIM pobjCommandBuilder As New OleDbCommand Builder (pobj DataAdapter) pobjCommandBuilder.DeriveParameters(pobjCommand)Be careful while USING “DeriveParameters” METHOD as it NEEDS an extra TRIP to the Datastore which can be very inefficient CommandBuilder builds “Parameter” objects automatically. Below is a simple code which uses commandbuilder to load its parameter objects. Be careful while using “DeriveParameters” method as it needs an extra trip to the Datastore which can be very inefficient |
|
| 23. |
How Can We Add Relation's Between Table In A Dataset ? |
|
Answer» Answer : DIM objRelation As DATARELATION objRelation=New DataRelation ("CustomerAddresses", objDataSet. Tables ("Customer"). COLUMNS("Custid") ,objDataSet. Tables("Addresses"). Columns ("Custid_fk")) objDataSet.Relations. Add(objRelation) //Relations can be added between “DataTable” OBJECTS using the “DataRelation” object. //Above sample CODE is trying to build a relationship between “Customer” and “Addresses” “Datatable” using “CustomerAddresses” “DataRelation” object. |
|
| 24. |
What Is Basic Use Of "dataview" ? |
|
Answer» “DataView” represents a complete table or can be small section of rows depending on some criteria. It is best used for sorting and finding data with in “datatable”. Dataview has the following method’s :- Find: It takes a array of values and returns the index of the row. FindRow: This also takes array of values but returns a COLLECTION of “DataRow”. If we want to MANIPULATE data of “DataTable” object create “DataView” (USING the “DefaultView” we can create “DataView” object) of the “DataTable” object and use the following FUNCTIONALITIES :- AddNew: ADDS a new row to the “DataView” object. Delete Deletes the specified row from “DataView” object. “DataView” represents a complete table or can be small section of rows depending on some criteria. It is best used for sorting and finding data with in “datatable”. Dataview has the following method’s :- Find: It takes a array of values and returns the index of the row. FindRow: This also takes array of values but returns a collection of “DataRow”. If we want to manipulate data of “DataTable” object create “DataView” (Using the “DefaultView” we can create “DataView” object) of the “DataTable” object and use the following functionalities :- AddNew: Adds a new row to the “DataView” object. Delete Deletes the specified row from “DataView” object. |
|
| 25. |
How Can We Add/remove Row's In "datatable" Object Of "dataset" ? |
|
Answer» “Datatable” PROVIDES “NewRow” method to add new row to “DataTable”. “DataTable” has “DataRowCollection” object which has all ROWS in a “DataTable” object. FOLLOWING are the METHODS provided by “DataRowCollection” object :- Add: Adds a new row in DataTable Remove It REMOVES a “DataRow” object from “DataTable” RemoveAt: It removes a “DataRow” object from “DataTable” depending on index position of the “DataTable”. “Datatable” provides “NewRow” method to add new row to “DataTable”. “DataTable” has “DataRowCollection” object which has all rows in a “DataTable” object. Following are the methods provided by “DataRowCollection” object :- Add: Adds a new row in DataTable Remove It removes a “DataRow” object from “DataTable” RemoveAt: It removes a “DataRow” object from “DataTable” depending on index position of the “DataTable”. |
|
| 26. |
How Can We Save All Data From Dataset ? |
|
Answer» Answer :
// create the data adapter
SqlDataAdapter dataAdapter = NEW Then, when we've finished making our changes to the DataSet via the DataGrid, we call dataAdapter.Update(dataSet);and the database will now contain the changes we have made. Then, when we've finished making our changes to the DataSet via the DataGrid, we call and the database will now contain the changes we have made. |
|
| 27. |
Which Is The Best Place To Store Connectionstring In .net Projects ? |
|
Answer» 264 Config files are the BEST places to store connectionstrings. If it is a web-based APPLICATION “Web.config” FILE will be used and if it is a WINDOWS application “App.config” files will be used. 264 Config files are the best places to store connectionstrings. If it is a web-based application “Web.config” file will be used and if it is a windows application “App.config” files will be used. |
|
| 28. |
How Can We Fine Tune The Command Object When We Are Expecting A Single Row ? |
|
Answer» Again CommandBehaviour enumeration provides TWO values SingleResult and SingleRow. If you are expecting a SINGLE value then PASS “CommandBehaviour.SingleResult” and the query is optimized accordingly, if you are expecting single ROW then pass “CommandBehaviour.SingleRow” and query is optimized according to single row. Again CommandBehaviour enumeration provides two values SingleResult and SingleRow. If you are expecting a single value then pass “CommandBehaviour.SingleResult” and the query is optimized accordingly, if you are expecting single row then pass “CommandBehaviour.SingleRow” and query is optimized according to single row. |
|
| 29. |
I Want To Force The Datareader To Return Only Schema Of The Datastore Rather Than Data ? |
|
Answer» pobjDataReader = pobjCommand.ExecuteReader(CommandBehavior.SchemaOnly). pobjDataReader = pobjCommand.ExecuteReader(CommandBehavior.SchemaOnly). |
|
| 30. |
How Can We Force The Connection Object To Close After My Datareader Is Closed ? |
|
Answer» COMMAND method EXECUTEREADER TAKES a parameter called as CommandBehavior where in we can specify saying close connection automatically after the Datareader is close. pobjDataReader = pobj Command .Execute Reader (CommandBehavior.CloseConnection) Command method Executereader takes a parameter called as CommandBehavior where in we can specify saying close connection automatically after the Datareader is close. pobjDataReader = pobj Command .Execute Reader (CommandBehavior.CloseConnection) |
|
| 31. |
What Are The Various Objects In Dataset ? |
|
Answer» Dataset has a collection of DataTable object within the Tables collection. Each DataTable object contains a collection of DataRow OBJECTS and a collection of DataColumn objects. There are also COLLECTIONS for the primary keys, CONSTRAINTS, and default values used in this table which is called as constraint collection, and the parent and child relationships between the tables. FINALLY, there is a DefaultView object for each table. This is used to create a DataView object based on the table, so that the data can be searched, FILTERED or otherwise manipulated while displaying the data. Dataset has a collection of DataTable object within the Tables collection. Each DataTable object contains a collection of DataRow objects and a collection of DataColumn objects. There are also collections for the primary keys, constraints, and default values used in this table which is called as constraint collection, and the parent and child relationships between the tables. Finally, there is a DefaultView object for each table. This is used to create a DataView object based on the table, so that the data can be searched, filtered or otherwise manipulated while displaying the data. |
|
| 32. |
What Is Dataset Object? |
|
Answer» The DataSet provides the BASIS for DISCONNECTED storage and manipulation of RELATIONAL data. We fill it from a data STORE, work with it while disconnected from that data store, then reconnect and flush changes back to the data store if REQUIRED. The DataSet provides the basis for disconnected storage and manipulation of relational data. We fill it from a data store, work with it while disconnected from that data store, then reconnect and flush changes back to the data store if required. |
|
| 33. |
What Are Basic Methods Of Dataadapter ? |
|
Answer» There are three most commonly used METHODS of Dataadapter :- Fill :- Executes the SelectCommand to fill the DataSet object with data from the data source. It an also be used to update (refresh) an existing table in a DataSet with changes made to the data in the original datasource if there is a primary key in the table in the DataSet. FillSchema :- Uses the SelectCommand to extract just the schema for a table from the data source, and creates an empty table in the DataSet object with all the corresponding constraints. Update:- CALLS the RESPECTIVE InsertCommand, UpdateCommand, or DeleteCommand for each inserted, updated,or DELETED row in the DataSet so as to update the original data source with the changes made to the content of the DataSet. This is a little like the UpdateBatch method provided by the ADO Recordset object, but in the DataSet it can be used to update more than one table. There are three most commonly used methods of Dataadapter :- Fill :- Executes the SelectCommand to fill the DataSet object with data from the data source. It an also be used to update (refresh) an existing table in a DataSet with changes made to the data in the original datasource if there is a primary key in the table in the DataSet. FillSchema :- Uses the SelectCommand to extract just the schema for a table from the data source, and creates an empty table in the DataSet object with all the corresponding constraints. Update:- Calls the respective InsertCommand, UpdateCommand, or DeleteCommand for each inserted, updated,or deleted row in the DataSet so as to update the original data source with the changes made to the content of the DataSet. This is a little like the UpdateBatch method provided by the ADO Recordset object, but in the DataSet it can be used to update more than one table. |
|
| 34. |
What Is The Use Of Dataadapter ? |
|
Answer» These are objects that CONNECT one or more Command objects to a Dataset object. They provide LOGIC that would get data from the data store and populates the tables in the DataSet, or pushes the CHANGES in the DataSet BACK into the data store.An OleDbDataAdapter object is used with an OLE-DB provider A SqlDataAdapter object uses Tabular Data Services with MS SQL Server. These are objects that connect one or more Command objects to a Dataset object. They provide logic that would get data from the data store and populates the tables in the DataSet, or pushes the changes in the DataSet back into the data store.An OleDbDataAdapter object is used with an OLE-DB provider A SqlDataAdapter object uses Tabular Data Services with MS SQL Server. |
|
| 35. |
What Is The Use Of Command Objects ? |
|
Answer» They are used to connect connection object to Datareader or DATASET. Following are the methods provided by command object :- ExecuteNonQuery :- Executes the command defined in the CommandText property against the connection defined in the Connection property for a QUERY that does not RETURN any row (an UPDATE, DELETE or INSERT). Returns an Integer indicating the number of rows affected by the query. ExecuteReader :- Executes the command defined in the CommandText property against the connection defined in the Connection property. Returns a "reader" object that is connected to the resulting rowset within the database, allowing the rows to be RETRIEVED. ExecuteScalar :- Executes the command defined in the CommandText property against the connection defined in the Connection property. Returns only single value (effectively the first column of the first row of the resulting rowset) any other returned columns and rows are DISCARDED. It is fast and efficient when only a "singleton" value is required. They are used to connect connection object to Datareader or dataset. Following are the methods provided by command object :- ExecuteNonQuery :- Executes the command defined in the CommandText property against the connection defined in the Connection property for a query that does not return any row (an UPDATE, DELETE or INSERT). Returns an Integer indicating the number of rows affected by the query. ExecuteReader :- Executes the command defined in the CommandText property against the connection defined in the Connection property. Returns a "reader" object that is connected to the resulting rowset within the database, allowing the rows to be retrieved. ExecuteScalar :- Executes the command defined in the CommandText property against the connection defined in the Connection property. Returns only single value (effectively the first column of the first row of the resulting rowset) any other returned columns and rows are discarded. It is fast and efficient when only a "singleton" value is required. |
|
| 36. |
What Is The Use Of Connection Object ? |
|
Answer» They are USED to connect a data to a COMMAND object. An OleDb Connection object is used with an OLE-DB provider255 A SqlConnection object USES Tabular Data Services (TDS) with MS SQL Server. They are used to connect a data to a Command object. An OleDb Connection object is used with an OLE-DB provider255 A SqlConnection object uses Tabular Data Services (TDS) with MS SQL Server. |
|
| 37. |
What Are Major Difference Between Classic Ado And Ado.net ? |
|
Answer» Following are some major differences between classic ADO and ADO.NET: Both As in classic ADO we had client and server side cursors they are no more PRESENT in ADO.NET. Note it's a disconnected model so they are no more applicable. Locking is not supported due to disconnected model. All DATA persist in XML as COMPARED to classic ADO where data persisted in BINARY format also. Following are some major differences between classic ADO and ADO.NET: Both As in classic ADO we had client and server side cursors they are no more present in ADO.NET. Note it's a disconnected model so they are no more applicable. Locking is not supported due to disconnected model. All data persist in XML as compared to classic ADO where data persisted in Binary format also. |
|
| 38. |
What Is Difference Between Dataset And Datareader ? |
|
Answer» Following are some major differences between dataset and DATAREADER :- DataReader PROVIDES forward-only and read-only access to data, while the DataSet object can hold more than one table (in other words more than one rowset) from the same data SOURCE as well as the relationships between them. Dataset is a disconnected ARCHITECTURE while datareader is connected architecture. Dataset can persist CONTENTS while datareader can not persist contents, they are forward only. Following are some major differences between dataset and datareader :- DataReader provides forward-only and read-only access to data, while the DataSet object can hold more than one table (in other words more than one rowset) from the same data source as well as the relationships between them. Dataset is a disconnected architecture while datareader is connected architecture. Dataset can persist contents while datareader can not persist contents, they are forward only. |
|
| 39. |
What Are The Two Fundamental Objects In Ado.net ? |
|
Answer» DATAREADER and DATASET are the TWO FUNDAMENTAL OBJECTS in ADO.NET. Datareader and Dataset are the two fundamental objects in ADO.NET. |
|
| 40. |
Give An Example Scenario Of Using A Dataset And A Datareader? |
|
Answer» If you want to just read and DISPLAY the data(No updates, DELETES, or INSERTS) then USE a DataReader. If you want to just read and display the data(No updates, deletes, or inserts) then use a DataReader. |
|
| 41. |
What Is The Difference Between A Datareader And A Dataset? |
|
Answer» DataReader
DataSet
DataReader DataSet |
|
| 42. |
Can You Update The Database Using Datareader Object? |
|
Answer» No, You cannot update the database using DATAREADER object. DataReader is read-only, foward only. It reads ONE record at ATIME. After DataReader finishes READING the current record, it moves to the next record. There is no WAY you can go back to the previous record. No, You cannot update the database using DataReader object. DataReader is read-only, foward only. It reads one record at atime. After DataReader finishes reading the current record, it moves to the next record. There is no way you can go back to the previous record. |
|
| 43. |
What Are The Advantages Of Using Sql Stored Procedures Instead Of Adhoc Sql Queries In An Asp.net Web Application? |
|
Answer» Better Performance : As stored procedures are precompiled objects they execute faster than SQL queries. EVERY time we run a SQL query, the query has to be first compiled and then executed where as a stored procedure is ALREADY compiled. Hence executing stored procedures is much faster than executing SQL queries. Better Security: For a GIVEN stored procedure you can SPECIFY who has the rights to execute. You cannot do the same for an SQL query. Writing the SQL statements inside our code is usually not a good idea. In this way you expose your database schema (design) in the code which may be changed. Hence most of the time programmers use stored procedures instead of plain SQL statements. Reduced Network Traffic : Stored Procedures reside on the database server. If you have to execute a Stored Procedure from your ASP.NET web application you just specify the name of the Stored Procedure. So over the network you just send the name of the Stored Procedure. With an SQL query you have to send all the SQL statements over the network to the database server which could lead to increased network traffic. Better Performance : As stored procedures are precompiled objects they execute faster than SQL queries. Every time we run a SQL query, the query has to be first compiled and then executed where as a stored procedure is already compiled. Hence executing stored procedures is much faster than executing SQL queries. Better Security: For a given stored procedure you can specify who has the rights to execute. You cannot do the same for an SQL query. Writing the SQL statements inside our code is usually not a good idea. In this way you expose your database schema (design) in the code which may be changed. Hence most of the time programmers use stored procedures instead of plain SQL statements. Reduced Network Traffic : Stored Procedures reside on the database server. If you have to execute a Stored Procedure from your ASP.NET web application you just specify the name of the Stored Procedure. So over the network you just send the name of the Stored Procedure. With an SQL query you have to send all the SQL statements over the network to the database server which could lead to increased network traffic. |
|
| 44. |
What Is The Use Of Sqlparameter.direction Property? |
|
Answer» SqlParameter.Direction Property is USED to specify the Sql Parameter type - input-only, output-only, bidirectional, or a STORED PROCEDURE return value parameter. The DEFAULT is Input. SqlParameter.Direction Property is used to specify the Sql Parameter type - input-only, output-only, bidirectional, or a stored procedure return value parameter. The default is Input. |
|
| 45. |
How Do You Get The Total Number Of Columns In The Current Row Of A Sqldatareader Instance? |
|
Answer» FieldCount property can be USED to GET the total NUMBER of COLUMNS in the current row of a SqlData READER instance. FieldCount property can be used to get the total number of columns in the current row of a SqlData Reader instance. |
|
| 46. |
How Do You Programatically Check If A Specified Sqldatareader Instance Has Been Closed? |
|
Answer» USE the IsClosed PROPERTY of SqlDataReader to CHECK if a specified SqlDataReader instance has been closed. If IsClosed property RETURNS TRUE, the SqlDataReader instance has been closed else not closed. Use the IsClosed property of SqlDataReader to check if a specified SqlDataReader instance has been closed. If IsClosed property returns true, the SqlDataReader instance has been closed else not closed. |
|
| 47. |
How Do You Create An Instance Of Sqldatareader Class? |
|
Answer» To CREATE an instance of SqlDataReader CLASS, you must call the ExecuteReader method of the SqlCommand object, instead of DIRECTLY using a constructor. //Error! Cannot use SqlDataReader() constructor to create an instance of SqlDataReader class. SqlDataReader ReaderObject = NEW SqlDataReader(); //Call the ExecuteReader method of the SqlCommand object SqlCommand CommandObject = new SqlCommand(); SqlDataReader ReaderObject = CommandObject.ExecuteReader();Creating an instance of SqlDataReader class using SqlData Reader() constructor generates a COMPILE time error - The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined. To create an instance of SqlDataReader class, you must call the ExecuteReader method of the SqlCommand object, instead of directly using a constructor. Creating an instance of SqlDataReader class using SqlData Reader() constructor generates a compile time error - The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined. |
|
| 48. |
What Is Sqlcommand.commandtimeout Property Used For? |
|
Answer» CommandTimeout Property is used to Get or set the wait time before terminating the attempt to execute a COMMAND and generating an ERROR. //SPECIFY the CommandTimeout property valueSqlCommand CommandObject = NEW SqlCommand("StoredProcedureName", ConnectionObject); //Wait for 10 seconds to execute the Stored procedure CommandObject.CommandTimeout = 10; The time is in seconds. The DEFAULT is 30 seconds. CommandTimeout Property is used to Get or set the wait time before terminating the attempt to execute a command and generating an error. |
|
| 49. |
What Are The Methods That Can Ensure Asynchronous Execution Of The Transact-sql Statement Or Stored Procedure? |
Answer»
|
|
| 50. |
Can You Reuse A Sqlcommand Object? |
|
Answer» YES, you can RESET the CommandText property and REUSE the SqlCommand object. Yes, you can reset the CommandText property and reuse the SqlCommand object. |
|