OleDbCommand : OleDbCommand : ADO.Net C# Examples


C# Examples » ADO.Net » OleDbCommand »

 

OleDbCommand









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

class  MainClass
{
        static  void  Main(string[]  args)
        {
                string  ConnectionString  =  @"Provider=Microsoft.Jet.OLEDB.4.0;  Data  Source=c:\Northwind.mdb";
                OleDbConnection  conn  =  new  OleDbConnection(ConnectionString);

                conn.Open();
                OleDbCommand  cmd  =  new  OleDbCommand();
                cmd.CommandText  =  "SELECT  Count(*)  FROM  Customers";
                cmd.Connection  =  conn;

                int  counter  =  (int)cmd.ExecuteScalar();
                
                Console.WriteLine("Total  rows  returned  are  :"  +  counter.ToString());
                              
                conn.Close();                                    
        }
}
    
   
  
   



Output

Total rows returned are :91


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo ADO.Net
» OleDbCommand