ADO.NET Interview questions


Total available count: 25
Subject - Microsoft Technologies
Subsubject - ADO.NET

How to fill a DataSet?

A DataAdapter should be used in according to fill a DataSet. Please follow the below steps to fill a DataSet.

using System.Data;
using System.Data.SqlClient;

namespace SlightbookWeb
{
	public partial class Slightbook{
		public void FillDataset{
			SqlConnection con = new SqlConnection(ConnectionString);
			SqlCommand com = new SqlCommand(CommandText, con);

			SqlDataAdapter myAdapter = new SqlDataAdapter();
			myAdapter.SelectCommand = com;
			DataSet ds = new DataSet();
			try {
			con.Open();
			myAdapter.Fill(ds);
			} catch (Exception ex) {
			throw (ex)
			} finally {
			con.Close();
			}
		}
	}
}

 




Next 5 interview question(s)

1
How to connect a database through SqlConnection?
2
Explain the methods of DataAdapter.Update() and DataSetAcceptChanges()?
3
What is the meaning of object pooling?
4
What is the difference between DataSet.Copy() and DataSet.Clone()?
5
Types of DataSet in ADO.NET?

Comments