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