Excess

And the other way:

public void ImportResFromAccess2Excel(xl.Range Dest)
        {
            object oo = Type.Missing;
            //int recCount = 0;

            MakeADOConnection();
            ADODB.Recordset rs = new ADODB.Recordset();

            rs.Open(“qryFinalReportView”, mADOConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdStoredProc);
            Dest.CopyFromRecordset(rs, oo, oo);
            rs.MoveLast();
            mDataRowCount = rs.RecordCount;
            mDataColcount = rs.Fields.Count;

            rs.Close();
            CloseADOConnection();
        }

Via the gift of an ado recordset.

the conn string for that is

mADOConn.Open(“Provider=Microsoft.Jet.OLEDB.4.0;” + “Data Source=” + msDBPath + “;”, “”, “”, 0);

Thats against an mdb.

btw I made the mistake of copying that directly from the VS IDE – turns out thats almost as bad as Word for scabby random html. I repasted it through my current fave text editor (Notepad++)

Cheers

simon

2 Responses to “Excess”

  1. Mike Staunton Says:

    Simon

    Your conn string works for versions prior to 2007

    For those with Office 2007, according to Alexander & Clark’s book on Excel & Access Integration I think it should be Provider=Microsoft.ACE.OLEDB.12.0

    Mike

  2. Simon Says:

    Mike
    you can still use Jet against 2007 .mdb files
    if you are using .accb etc then yes you need something like

    .Open(“Provider=Microsoft.ACE.OLEDB.12.0;” +
    “Data Source=” + msDBPath + “;Persist Security Info=False;”, “”, “”, 0);

    I have no idea if there are any significant differences between them – I have been using both with no obvious diffs.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


%d bloggers like this: