OLEDB ODBC Helper

HOW TO:

Default.aspx.cs
using System.Data;
using System.Data.OleDb;

//- OLEDB Connection String
var MyStringConnection = "data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true";

//- Instantiate the ODBC Class
ncTools.ODBCHelper oDB = new ncTools.ODBCHelper();
//- Get the Records
 OleDbDataReader dr = oDB.MyOleDbRecordSet("SELECT * FROM Customers", MyStringConnection);
//- Check for end of file
if (dr.HasRows)
{
   //- Loop through all record found
   while (dr.Read())
   {
      //- Do your thing here
    }
}
dr.Close(); 
oDB = null; 

//=====================================================================================
//-- OLEDB Execute a store procedure.
//=====================================================================================
//- OLEDB Connection String
var MyStringConnection = "data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true";
//- Instantiate the ODBC Class
ncTools.ODBCHelper oDB = new ncTools.ODBCHelper();
//- Get the result
int iResult = oDB..OleDbExecuteQuery("spExecuteStoreProcedure", MyStringConnection);
if (iResult>0)
{
  //- Successfully Executed    
}
oDB=null;

Add Feedback