JakeyCakes
asked on
Modify Access Table code to also return the number of records in the specified table
Hi how could I modify my code below so it also returns the number of records in the table specified? Please help!
public bool TableExist(string tbl)//tbl indicates the name of the table
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString =
@"Provider=Microsoft.Jet.O LEDB.4.0;" + @"Data source=" + Access;
conn.Open();
System.Data.DataTable Tables = conn.GetOleDbSchemaTable(O leDbSchema Guid.Table s,new object[] {null,null,null,"TABLE"});
System.Data.DataRow[] dr = null;
dr = Tables.Select("TABLE_NAME = '" + tbl + "'");
if (dr.Length <=0)
return false; //if table is not found return false
else
//Problem line ==>Records = Tables.Rows.Count //integer Records should contain the number of records in the table tbl. This returns the number of tables in the database which is what I do not want
return true;
}
public bool TableExist(string tbl)//tbl indicates the name of the table
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString =
@"Provider=Microsoft.Jet.O
conn.Open();
System.Data.DataTable Tables = conn.GetOleDbSchemaTable(O
System.Data.DataRow[] dr = null;
dr = Tables.Select("TABLE_NAME = '" + tbl + "'");
if (dr.Length <=0)
return false; //if table is not found return false
else
//Problem line ==>Records = Tables.Rows.Count //integer Records should contain the number of records in the table tbl. This returns the number of tables in the database which is what I do not want
return true;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ooooh !! forget about my post .. I don't know why I thought *Tables* is a dataset!!
ASKER
DrAske Apologies for the lengthy delay in giving you the points - I have been extremely busy at work (for which I use this site for)