Functions to handle generic low level database operations using the SQL SELECT Language

Namespace: Wiker.WIDatabase
Assembly: 

Syntax

C#
public class WIDBUtil
Visual Basic
Public Class WIDBUtil
Visual C++
public ref class WIDBUtil

Examples

CopyC#
WIDBUtil dbUtil;
CDatabaseInfo DBInfo;
StringBuilder StrB;
int CompanyID;
string CompanyName;

/* 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";

dbUtil = new WIDBUtil(DBInfo);
if (dbUtil.LastError != eDBErrorCodes.None)
   {
   MessageBox.Show(string.Format("Failed To allocate dbUtil\n{0} - {1}", 
                   dbUtil.LastError.ToString(), dbUtil.LastErrorMessage));
   return(false);
   }

StrB = new StringBuilder(); /* Build Select Request */
StrB.Append("SELECT CompanyID, Name ");
StrB.Append("FROM tblCompany ");
StrB.Append("ORDER BY Name ASC");

if (!dbUtil.Open()) /* Open Database */
   {
   MessageBox.Show(string.Format("Failed To open database\n{0} - {1}", 
                   dbUtil.LastError.ToString(), dbUtil.LastErrorMessage));
   return(false);
   }

dbUtil.CommandText = StrB.ToString();

while (dbUtil.ReadRow()) /* Loop Through Results */
   {
   CompanyID   = dbUtil.ReadInt(0);
   CompanyName = dbUtil.ReadString(1);
   }

dbUtil.Close();

Inheritance Hierarchy

System..::..Object
  Wiker.WIDatabase..::..WIDBUtil

See Also