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

Threaded View

  1. #1
    Join Date
    Oct 2011
    Posts
    1

    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 ")
    Try
    Con.Open()
    Catch ex As InvalidOperationException
    MsgBox(ex.Message)
    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//
    Trans.Commit()
    Con.Close()
    End Sub
    Attached Images Attached Images

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured