Unhelpful exception message when trying to save data in Access db

Discussion in 'ASP .Net' started by Julia B, Jan 23, 2008.

  1. Julia B

    Julia B Guest

    All,

    I'm using .NET version 1.1 connecting to an Access back end db.

    I've got some code that fails during a Try Catch. The error message I get is
    this:

    {System.Reflection.TargetInvocationException}
    [System.Reflection.TargetInvocationException]:
    {System.Reflection.TargetInvocationException}
    HelpLink: Nothing
    InnerException: {System.Data.OleDb.OleDbException}
    Message: "Exception has been thrown by the target of an invocation."
    Source: "mscorlib"

    The failure point is the ExecuteNonQuery().

    Here's the code:

    Friend Sub EditQuote( _
    ByVal recordID As String, ByVal brNo As String, ByVal cat As
    Integer, ByVal recDt As String, _
    ByVal enqDt As String, ByVal fromName As String, ByVal fromTitle As
    String, ByVal cust As Integer, _
    ByVal add1 As String, ByVal add2 As String, ByVal add3 As String,
    ByVal county As String, _
    ByVal country As String, ByVal postcode As String, ByVal custRef As
    String, ByVal equip As String, _
    ByVal pricingBasis As Integer, ByVal currency As Integer, ByVal
    subBy As String, _
    ByVal subDt As String, ByVal ROE As String, ByVal pricedBy As
    String, ByVal pricedDt As String, _
    ByVal validity As String, ByVal genDt As String, ByVal expDt As
    String, ByVal sentCustBy As String, _
    ByVal sentCustDt As String, ByVal comments As String, ByVal
    letterHead As String, _
    ByVal stdLetter As Boolean, ByVal covLetter As String, ByVal
    exLicText As String, _
    ByVal delTermsText As String, ByVal assumptions As String, ByVal
    commQs As String, _
    ByVal techQs As String, ByVal quoteStatus As String)
    'this edits a current record
    'firstly set the parameters
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Assumptions",
    System.Data.OleDb.OleDbType.VarWChar, 0, "Assumptions"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("BRNo", System.Data.OleDb.OleDbType.Integer,
    0, "BRNo"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Category",
    System.Data.OleDb.OleDbType.Integer, 0, "Category"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Comments",
    System.Data.OleDb.OleDbType.VarWChar, 0, "Comments"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CommercialQuestions",
    System.Data.OleDb.OleDbType.VarWChar, 0, "CommercialQuestions"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CoveringLetterText",
    System.Data.OleDb.OleDbType.VarWChar, 0, "CoveringLetterText"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Currency",
    System.Data.OleDb.OleDbType.Integer, 0, "Currency"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustAddressCountry",
    System.Data.OleDb.OleDbType.VarWChar, 50, "CustAddressCountry"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustAddressCounty",
    System.Data.OleDb.OleDbType.VarWChar, 50, "CustAddressCounty"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustAddressLine1",
    System.Data.OleDb.OleDbType.VarWChar, 50, "CustAddressLine1"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustAddressLine2",
    System.Data.OleDb.OleDbType.VarWChar, 50, "CustAddressLine2"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustAddressLine3",
    System.Data.OleDb.OleDbType.VarWChar, 50, "CustAddressLine3"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustAddressPostcode",
    System.Data.OleDb.OleDbType.VarWChar, 50, "CustAddressPostcode"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Customer",
    System.Data.OleDb.OleDbType.Integer, 0, "Customer"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("CustomerRef",
    System.Data.OleDb.OleDbType.VarWChar, 255, "CustomerRef"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("DeliveryTermsText",
    System.Data.OleDb.OleDbType.VarWChar, 0, "DeliveryTermsText"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("EnqDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "EnqDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("EnqRecDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "EnqRecDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Equipment",
    System.Data.OleDb.OleDbType.VarWChar, 255, "Equipment"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("ExpiryDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "ExpiryDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("ExportLicensingText",
    System.Data.OleDb.OleDbType.VarWChar, 0, "ExportLicensingText"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("GeneratedDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "GeneratedDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("LetterHeading",
    System.Data.OleDb.OleDbType.VarWChar, 255, "LetterHeading"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("PricedBy",
    System.Data.OleDb.OleDbType.VarWChar, 50, "PricedBy"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("PricedDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "PricedDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("PricingBasis",
    System.Data.OleDb.OleDbType.Integer, 0, "PricingBasis"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("RecFromName",
    System.Data.OleDb.OleDbType.VarWChar, 50, "RecFromName"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("RecFromTitle",
    System.Data.OleDb.OleDbType.VarWChar, 50, "RecFromTitle"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("ROE", System.Data.OleDb.OleDbType.Double,
    0, "ROE"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("SentToCustBy",
    System.Data.OleDb.OleDbType.VarWChar, 50, "SentToCustBy"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("SentToCustDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "SentToCustDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("StandardLetter",
    System.Data.OleDb.OleDbType.Boolean, 2, "StandardLetter"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Status",
    System.Data.OleDb.OleDbType.VarWChar, 50, "Status"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("SubmittedBy",
    System.Data.OleDb.OleDbType.VarWChar, 50, "SubmittedBy"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("SubmittedDate",
    System.Data.OleDb.OleDbType.DBDate, 0, "SubmittedDate"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("TechnicalQuestions",
    System.Data.OleDb.OleDbType.VarWChar, 0, "TechnicalQuestions"))
    QuoteUpdateCommand.Parameters.Add(New
    System.Data.OleDb.OleDbParameter("Validity",
    System.Data.OleDb.OleDbType.Integer, 0, "Validity"))

    'set the data for the parameters
    With QuoteUpdateCommand
    .Parameters("Assumptions").Value = assumptions
    If brNo = "" Then
    .Parameters("BRNo").Value = DBNull.Value
    Else
    .Parameters("BRNo").Value = CInt(brNo)
    End If
    If cat = 0 Then
    .Parameters("Category").Value = DBNull.Value
    Else
    .Parameters("Category").Value = cat
    End If
    .Parameters("Comments").Value = comments
    .Parameters("CommercialQuestions").Value = commQs
    .Parameters("CoveringLetterText").Value = covLetter
    If currency = 0 Then
    .Parameters("Currency").Value = DBNull.Value
    Else
    .Parameters("Currency").Value = currency
    End If
    .Parameters("CustAddressCountry").Value = country
    .Parameters("CustAddressCounty").Value = county
    .Parameters("CustAddressLine1").Value = add1
    .Parameters("CustAddressLine2").Value = add2
    .Parameters("CustAddressLine3").Value = add3
    .Parameters("CustAddressPostcode").Value = postcode
    If cust = 0 Then
    .Parameters("Customer").Value = DBNull.Value
    Else
    .Parameters("Customer").Value = cust
    End If
    .Parameters("CustomerRef").Value = custRef
    .Parameters("DeliveryTermsText").Value = delTermsText
    If enqDt = "#00/00/00#" Then
    .Parameters("EnqDate").Value = DBNull.Value
    Else
    .Parameters("EnqDate").Value = CDate(enqDt)
    End If
    If recDt = "#00/00/00#" Then
    .Parameters("EnqRecDate").Value = DBNull.Value
    Else
    .Parameters("EnqRecDate").Value = CDate(recDt)
    End If
    .Parameters("Equipment").Value = equip
    If expDt = "" Then
    .Parameters("ExpiryDate").Value = DBNull.Value
    Else
    .Parameters("ExpiryDate").Value = CDate(expDt)
    End If
    .Parameters("ExportLicensingText").Value = exLicText
    If genDt = "" Then
    .Parameters("GeneratedDate").Value = DBNull.Value
    Else
    .Parameters("GeneratedDate").Value = CDate(genDt)
    End If
    .Parameters("LetterHeading").Value = letterHead
    .Parameters("PricedBy").Value = pricedBy
    If pricedDt = "" Then
    .Parameters("PricedDate").Value = DBNull.Value
    Else
    .Parameters("PricedDate").Value = CDate(pricedDt)
    End If
    If pricingBasis = 0 Then
    .Parameters("PricingBasis").Value = DBNull.Value
    Else
    .Parameters("PricingBasis").Value = pricingBasis
    End If
    .Parameters("RecFromName").Value = fromName
    .Parameters("RecFromTitle").Value = fromTitle
    If ROE = "" Then
    .Parameters("ROE").Value = DBNull.Value
    Else
    .Parameters("ROE").Value = CDbl(ROE)
    End If
    .Parameters("SentToCustBy").Value = sentCustBy
    If sentCustDt = "" Then
    .Parameters("SentToCustDate").Value = DBNull.Value
    Else
    .Parameters("SentToCustDate").Value = sentCustDt
    End If
    .Parameters("StandardLetter").Value = stdLetter
    .Parameters("Status").Value = quoteStatus
    .Parameters("SubmittedBy").Value = subBy
    If subDt = "" Then
    .Parameters("SubmittedDate").Value = DBNull.Value
    Else
    .Parameters("SubmittedDate").Value = CDate(subDt)
    End If
    .Parameters("TechnicalQuestions").Value = techQs
    If validity = "" Then
    .Parameters("Validity").Value = DBNull.Value
    Else
    .Parameters("Validity").Value = CInt(validity)
    End If
    End With

    'now update the record
    Connection.Open()
    Try
    QuoteUpdateCommand.ExecuteNonQuery()
    Catch ex As Exception
    System.Web.HttpContext.Current.Session("dbErrorQuote") = "True"
    Finally
    Connection.Close()
    End Try

    End Sub

    I'm pretty sure that it's not a db connection issue, as I'm able to update
    data in the same db from another form, just not this one. I've checked the
    data being submitted to the procedure and it's all OK. I'm really confused.
    Any ideas of other places to look?

    Any help greatly appreciated!

    Thanks

    P.S. Stack trace is this:

    StackTrace: " at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object
    obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
    culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
    at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
    BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
    culture, Boolean verifyAccess)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
    invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    at Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o,
    MethodBase method, ParameterInfo[] Parameters, Object[] args, Type objType,
    IReflect objIReflect)
    at
    Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o,
    Type objType, String name, Object[] args, String[] paramnames, Boolean[]
    CopyBack, Boolean IgnoreReturn)
    at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
    Type objType, String name, Object[] args, String[] paramnames, Boolean[]
    CopyBack)
    at GSContractsCSDs.UpdateQuoteData.EditQuote(String recordID, String
    brNo, Int32 cat, String recDt, String enqDt, String fromName, String
    fromTitle, Int32 cust, String add1, String add2, String add3, String county,
    String country, String postcode, String custRef, String equip, Int32
    pricingBasis, Int32 currency, String subBy, String subDt, String ROE, String
    pricedBy, String pricedDt, String validity, String genDt, String expDt,
    String sentCustBy, String sentCustDt, String comments, String letterHead,
    Boolean stdLetter, String covLetter, String exLicText, String delTermsText,
    String assumptions, String commQs, String techQs, String quoteStatus) in
    c:\inetpub\wwwroot\GSContractsCSDs\Quotes\UpdateQuoteData.vb:line 420"
    TargetSite: {System.Reflection.RuntimeMethodInfo}
    Julia B, Jan 23, 2008
    #1
    1. Advertising


  2. > {System.Reflection.TargetInvocationException}
    > [System.Reflection.TargetInvocationException]:
    > {System.Reflection.TargetInvocationException}
    > HelpLink: Nothing
    > InnerException: {System.Data.OleDb.OleDbException}
    > Message: "Exception has been thrown by the target of an invocation."
    > Source: "mscorlib"



    > Any ideas of other places to look?



    Inspect the InnerException property of the exception being thrown using the
    debugger. I'm sure it will be more helpful to you.
    Scott Roberts, Jan 23, 2008
    #2
    1. Advertising

  3. Julia B

    Julia B Guest

    Re: Unhelpful exception message when trying to save data in Access

    Thanks Scott, I didn't appreciate I could do that. It's really helped, it
    appears it's a parameter issue.

    Julia

    "Scott Roberts" wrote:

    >
    > > {System.Reflection.TargetInvocationException}
    > > [System.Reflection.TargetInvocationException]:
    > > {System.Reflection.TargetInvocationException}
    > > HelpLink: Nothing
    > > InnerException: {System.Data.OleDb.OleDbException}
    > > Message: "Exception has been thrown by the target of an invocation."
    > > Source: "mscorlib"

    >
    >
    > > Any ideas of other places to look?

    >
    >
    > Inspect the InnerException property of the exception being thrown using the
    > debugger. I'm sure it will be more helpful to you.
    >
    >
    Julia B, Jan 23, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. teo
    Replies:
    1
    Views:
    447
  2. Replies:
    2
    Views:
    558
    sloan
    Aug 18, 2006
  3. Replies:
    0
    Views:
    198
  4. OccasionalFlyer

    Unhelpful HTML validation

    OccasionalFlyer, Mar 29, 2012, in forum: HTML
    Replies:
    2
    Views:
    560
    Jonathan N. Little
    Apr 3, 2012
  5. John Nagle

    Unhelpful traceback

    John Nagle, Mar 7, 2013, in forum: Python
    Replies:
    8
    Views:
    111
    Dave Angel
    Mar 8, 2013
Loading...

Share This Page