using System; using System.Windows.Forms; using System.Data.OleDb; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string connetionString = null; OleDbConnection cnn ; OleDbCommand cmd ; string sql = null; connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"; sql = "Your SQL Statement Here like Select Count(*) from product"; cnn = new OleDbConnection(connetionString); try { cnn.Open(); cmd = new OleDbCommand(sql, cnn); Int32 count = Convert.ToInt32(cmd.ExecuteScalar()); cmd.Dispose(); cnn.Close(); MessageBox.Show (" No of Rows " + count); } catch (Exception ex) { MessageBox.Show("Can not open connection ! "); } } } }