Wednesday, April 15, 2009

Count Record in access database C# asp.net

string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\sites\\abcDB.mdb";
     
        string Strsql1 = "select count(Itmno) from svprodtab where Itmno='" + ItemnoCnt + "'";
        
        OleDbConnection MyConnCount = new OleDbConnection(connectionString);
        OleDbCommand cmd1 = new OleDbCommand(Strsql1, MyConnCount);
        MyConnCount.Open();
        int itmcnt = cmd1.ExecuteNonQuery();
        Response.Write("count>" + itmcnt);
        MyConnCount.Close();
        

No comments: