Interview question for data handling in C#/ .NET

1. What are the data access namespaces in .NET?

The most common data access namespaces : System.Data System.Data.OleDb System.Data.SQLClient System.Data.SQLTypes System.Data.XMLv

2. What is a Clustered Index?

The data rows are stored in order based on the clustered index key. Data stored is in a sequence of the index. In a clustered index, the physical order of the rows in the table is the same as the logical (indexed) order of the key values. A table can contain only one clustered index. A clustered index usually provides faster access to data than does a non-clustered index.

3. What is a Non-Clustered Index?

The data rows are not stored in any particular order, and there is no particular order to the sequence of the data pages. In a clustered index, the physical order of the rows in the table is not same as the logical (indexed) order of the key values.

4. Whate are different types of Commands available with DataAdapter ?

The SqlDataAdapter has SelectCommand InsertCommand DeleteCommand UpdateCommand

5. Which method do you invoke on the DataAdapter control to load your generated dataset with data?

DataAdapter’ fill () method is used to fill load the data in dataset.

6. What are the different methods available under sqlcommand class to access the data?

ExecuteReader - Used where one or more records are returned - SELECT Query. ExecuteNonQuery - Used where it affects a state of the table and no data is being queried - INSERT, UPDATE, DELETE, CREATE and SET queries. ExecuteScalar - Used where it returns a single record.

7. What is a DataSet?

A DataSet is an in memory representation of data loaded from any data source.

8. What is a DataTable?

A DataTable is a class in .NET Framework and in simple words a DataTable object represents a table from a database.

9. What is the data provider name to connect to Access database?

Microsoft.Access

10. What is difference between Dataset. clone and Dataset.copy?

Clone: - It only copies structure, does not copy data. Copy: - Copies both structure and data.

11. What is difference 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.

12. What is DataAdapter?

A data adapter represents a set of methods used to perform a two-way data updating mechanism between a disconnected DataTable and the database. It aggregates four commands: select, update, insert and delete command. One adapter can only generate and fill one table in a DataSet. DataSet contains the data from the DataAdapter which is the bridge between the DataSet and Database. DataAdapter provides the way to retrieve and save data between the DataSet and Database. It accomplishes this by means of request to the SQL Commands made against the database.

13. What is basic use of DataView?

“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”.

14. What is a stored procedure?

A stored procedure is a precompiled executable object that contains one or more SQL statements. A stored procedure may be written to accept inputs and return output

15. What is the difference between OLEDB Provider and SqlClient ?

SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer.

16. What is Data Provider?

A set of libraries that is used to communicate with data source. Eg: SQL data provider for SQL, Oracle data provider for Oracle, OLE DB data provider for access, excel or mysql.

17. What is the DataTableCollection?

An ADO.NET DataSet contains a collection of zero or more tables represented by DataTable objects. The DataTableCollection contains all the DataTable objects in a DataSet.

18. How to creating a SqlConnection Object?

SqlConnection conn = new SqlConnection("Data Source=DatabaseServer;Initial Catalog=Northwind;User ID=YourUserID;Password=YourPassword");

19. How to creating a SqlCommand Object?

It takes a string parameter that holds the command you want to execute and a reference to a SqlConnection object. SqlCommand cmd = new SqlCommand("select CategoryName from Categories", conn);

20. How to load multiple tables into dataset?

SqlDataAdapter da = new SqlDataAdapter("Select * from Id; Select * from Salry", mycon); da.Fill(ds); ds.Tables[0].TableName = "Id"; ds.Tables[1].TableName = "Salary";
21. What is the provider and namespaces being used to access oracle database?
system.data.oledb

22. What is the difference between SqlCommand and SqlCommandBuilder?

SQLCommand is used to retrieve or update the data from database. SQLCommandBuilder object is used to build & execute SQL (DML) queries like select insert update& delete.

23. What is the use of SqlCommandBuilder?

SQL CommandBuilder object is used to build & execute SQL (DML) queries like select insert update& delete.

24. What are managed providers?

A managed provider is analogous to ODBC driver or OLEDB provider. It performs operation of communicating with the database. ADO.NET currently provides two distinct managed providers. The SQL Server managed provider is used with SQL server and is a very efficient way of communicating with SQL Server. OLEDB managed provider is used to communicate with any OLEDB compliant database like Access or Oracle.

25. How do I delete a row from a DataTable?

ds.Tables("data_table_name").Rows(i).Delete dscmd.update(ds,"data_table_name")

26. What inside in DataSet?

Inside DataSet much like in Database, there are tables, columns, constraints, relationships, views and so forth.

27. What are basic methods of Dataadapter?

Fill FillSchema Update

28. What are the various methods provided by the dataset object to generate XML?

ReadXML : Read’s a XML document in to Dataset. GetXML : This is a function which returns the string containing XML document. WriteXML : This writes a XML data to disk.

29. What is DataSet Object?

Dataset is a disconnected, in-memory representation of data. It can contain multiple data table from different database.

30. What is difference between Optimistic and Pessimistic locking?

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.

31. What is Execute Non Query?

The ExecuteNonQuery() is one of the most frequently used method in SqlCommand Object, and is used for executing statements that do not return result sets (ie. statements like insert data , update data etc.).

32. What is datagrid?

The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.