Results 1 to 4 of 4

Thread: access databases

  1. #1
    morganrobin Guest

    access databases

    Can anyone help me out with any info on how to add access database tables to another table using install script. I am fairly new to install shield and know how to include a database but that is about as far as I have gotten. We have several database tables that we need to merge into a clients database. Both are access databases. Any info would be helpful....thanks....robin

  2. #2
    Join Date
    Sep 2002
    Location
    India
    Posts
    156
    you can connect to the database through installscipt using ADO objects.Later can create tables and populate them with data ..

    Here is a sample code..
    szADOObjID = "ADODB.Connection";
    set pADOObj = CreateObject(szADOObjID);
    szConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=<path>\\database.mdb;" +
    "User Id=admin;" +
    "Password=" ;
    try
    pADOObj.Open( szConnectionStr );
    szSql = "create table tablename(userid varchar(50),username varchar(50))";
    pADOObj.Execute(szSql);
    catch
    MessageBox(Err.Description,SEVERE);
    endcatch;

    HTH..

  3. #3
    morganrobin Guest
    Thanks for responding to my post. Do you have time for a little more chat? I am not sure how to call the connection from Install Shield or Create the tables. I would appreciate any more info you can give....Thanks....robin

  4. #4
    Join Date
    Sep 2002
    Location
    India
    Posts
    156
    Here is a sample code that will work in Developer 7 project..
    Declaration for the function ;
    prototype ConnectToAcsDatabase(HWND);
    Defination for the function starts from here
    function ConnectToAcsDatabase(hMSI)
    STRING szConnectionStr,szADOObjID,szSql ;
    OBJECT pADOObj;

    begin
    szADOObjID = "ADODB.Connection"; connection object ID
    set pADOObj = CreateObject(szADOObjID); create an connection object using ADO
    szConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=F:\\TestAcs\\aboutdelphi.mdb;" +
    "User Id=admin;" +
    "Password=" ; connection string
    Here data source is the path of your mdb file

    try
    pADOObj.Open( szConnectionStr ); Open the connection
    szSql = "create table sonata(userid varchar(50),username varchar(50))"; can give any sql command for execution
    pADOObj.Execute(szSql); execute the sql string
    catch
    MessageBox(Err.Description,SEVERE);
    endcatch;

    end;

    You can call this function using a Custom Action..
    For example
    declaration

    export prototype CallingFunction(HWND)

    defination
    function CallingFunction(hMSI)
    begin
    ConnectToAcsDatabase(HWND);
    end;
    Create a custom action for CallingFunction and execute it at any sequence..
    HTH..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •