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 4 interview question(s)

1
Explain about ADO.NET namespaces which are required to connect database?
2
How to convert a DataSet into a DataReader?
3
What are the differences between ADO and ADO.NET?
4
Explain about ADO.NET support namespaces?