Examples

Overload List

  NameDescription
Public methodCount(String)
Returns number of rows in table
Public methodCount(String, String)
Returns number of rows in table that are not null

Examples

CopyC#
WIDatabase WIDB;
CDatabaseInfo DBInfo;
int Total, PersonTotal;

/* Create CDatabaseInfo object and populate with database login info */
DBInfo = new CDatabaseInfo();
DBInfo.DatabaseType = eDatabaseType.SQL;
DBInfo.Location     = "SqlServer";
DBInfo.DBName       = "TestDatabase";
DBInfo.Username     = "LoginName";
DBInfo.Password     = "LoginPassword";

/* Create new instance of WIDatabase */
WIDB = new WIDatabase(DBInfo);

/*----------------------------------------------------------------------------*/

/* Search table 'tblPhone' */
WIDB.Search.Table("tblPhone");

/* Return number of records in table using alias 'Count' */
WIDB.Search.Count("Count");

/* Return number of records where column 'PersonID' is not null */
WIDB.Search.Count("PersonCount", "PersonID");

if (!WIDB.Search.Execute())
   {
   MessageBox.Show(string.Format("Failed To Search Table\n{0} - {1}", 
                   WIDB.LastError.ToString(), WIDB.LastErrorMessage));
   return(false);
   }

if (!WIDB.Search.Read())
   {
   MessageBox.Show(string.Format("Failed To Read Table\n{0} - {1}", 
                   WIDB.LastError.ToString(), WIDB.LastErrorMessage));
   return(false);
   }


if (!WIDB.Search.Get("Count", out Total))
   {
   MessageBox.Show(string.Format("Failed To Get Results\n{0} - {1}", 
                   WIDB.LastError.ToString(), WIDB.LastErrorMessage));
   return(false);
   }

if (!WIDB.Search.Get("PersonCount", out PersonTotal))
   {
   MessageBox.Show(string.Format("Failed To Get Results\n{0} - {1}", 
                   WIDB.LastError.ToString(), WIDB.LastErrorMessage));
   return(false);
   }

WIDB.Close();

See Also