How to Trap Error Messages when getting data from a linked Access Table (asp2.net)

Last post 07-04-2008 10:03 PM by Joël Hébert. 1 replies.

Sort Posts:

  • How to Trap Error Messages when getting data from a linked Access Table (asp2.net)

    07-03-2008, 4:46 PM
    • Member
      2 point Member
    • barnnabyb
    • Member since 08-08-2007, 10:53 AM
    • Posts 14

    Hi,

    I am developing an excel import tool, where the user imports a set excel sheet and it populates it into the SQL database. Currently the structure is as follows:

    User selects the Excel Sheet > gets uploaded and called upload.xls > is read through an access.mdb file using a linked table referring to a named reference called Data > shows it on web page (initial check) > imports it to a temp SQL Server Table > shows it on screen, showing only unique records (ones that aren't in the system) > data is imported.

    It works perfectly well if the user imports the correct excel sheet, but if they don't it alerts the user with a nasty error (see below). Does anyone know how to trap this - and just goto another page?

    If anyone could help me, I'd be grateful.

    Regards,

    Barnaby

     The Microsoft Jet database engine cannot find the input table or query 'Data'.  Make sure it exists and that its name is spelled correctly.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot find the input table or query 'Data'.  Make sure it exists and that its name is spelled correctly.

    Source Error:

    Line 6577:            this.Adapter.SelectCommand = this.CommandCollection[0];
    Line 6578:            DataSet_XLSImport.DataDataTable dataTable = new DataSet_XLSImport.DataDataTable();
    Line 6579:            this.Adapter.Fill(dataTable);
    Line 6580:            return dataTable;
    Line 6581:        }

     

  • Re: How to Trap Error Messages when getting data from a linked Access Table (asp2.net)

    07-04-2008, 10:03 PM
    Answer
    • Contributor
      4,623 point Contributor
    • Joël Hébert
    • Member since 07-20-2005, 2:07 PM
    • Ottawa Canada
    • Posts 679
    • TrustedFriends-MVPs

    try

    catch e as System.Data.OleDb.OleDbException

    'redirect here or warm of bad file

    finaly

    'do code that always executes no matter what

    end try

    Joël Hébert [MVP ASP.NET]

    Opulent ASP Development Inc.
    www.opulentasp.com
    Ottawa,Canada

    Click "Mark as Answer" on the posts that helped you to help future readers to get the solutions
Page 1 of 1 (2 items)
Microsoft Communities