CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2011

    error: oleDbexception was unhandled

    Hai i have a probleam with my coding.The error which i got is olehDBexeception was unhandled.In my coding here i am developing function
    use to subtract number in database based on user input.I dont how to solve this
    error , please some help me to correct my coding here. I also highlight the line cause\
    an error and also i attach picture of the probleam.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    'open db connection'
    Dim Con As New OleDb.OleDbConnection("Provider=SQLOLEDB ;Data Source=Danawa;Initial Catalog=Store;Integrated Security=SSPI ")
    Catch ex As InvalidOperationException
    End Try

    'start transaction'
    Dim Trans = Con.BeginTransaction

    'define a sql command statement'
    Dim cmd As New OleDb.OleDbCommand("UPDATE ItemIn SET Itemquantity= Itemquantity - @IQ WHERE ItemName=@IN", Con, Trans)
    cmd.Parameters.AddWithValue("@IQ", Int32.Parse(ItemquantityTextBox.Text))
    cmd.Parameters.AddWithValue("@IN", ItemNameComboBox.Text)

    'execute the command'
    cmd.ExecuteNonQuery() // The probleam are from here//
    End Sub
    Attached Images Attached Images  

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: error: oleDbexception was unhandled

    There should have been more info on the error, could you tell us more?
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: error: oleDbexception was unhandled

    Think you need to redo that query. Does it run in Access?

    Select a line, and then UPDATE it.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.