views:

30

answers:

0

Hi I am trying to embed a Microsoft Access database file into my Class assembly DLL. I want my code to reference the resource file and use it with a ADODB.Connection object. Any body know a simpler way, or an easier way? Or what is wrong with my code, when i added the resource file it added me dataset definitions, but i have no idea what to do with those. The connection string I am trying below is from an automatically generated app.config. I did add the item as a resource...

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ConsoleApplication1.Resources;//SPPrinterLicenses
using System.Data.OleDb;
using ADODB; 
using System.Configuration;

namespace ConsoleApplication1
{
    class SharePointPrinterManager
    {
        public static bool IsValidLicense(string HardwareID)
        {
            OleDbDataAdapter da = new OleDbDataAdapter();
            DataSet ds = new DataSet();
            ADODB.Connection adoCn = new Connection();
            ADODB.Recordset adoRs = new Recordset();
               //**open command below fails**
            adoCn.Open(
                @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Resources\SPPrinterLicenses.accdb;Persist Security Info=True", "", "", 1);
            adoRs.Open("Select * from AllWorkstationLicenses", adoCn,
                ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1);
            da.Fill(ds, adoRs, "AllworkstationLicenses");
            adoCn.Close();
            DataTable dt = new DataTable();
            //ds.Tables.
            return true;
        }
    }
}