combobox

Page 1 of 1

1 Replies - 1330 Views - Last Post: 11 October 2012 - 02:51 PM Rate Topic: -----

#1 shykxz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 11-October 12

combobox

Posted 11 October 2012 - 02:26 PM

i have some code here to save and update a record in the separate table in the database using the displaymember and valuemember of the combo box
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim cmd As New MySqlCommand
        If NewRecord = True Then
            connect()
            cmd = New MySqlCommand("insert into books (bookid, bookname, authorname, bookprice, bookstocks) values (bookid = " & txtBookID.Text & ", bookname = '" & txtBookName.Text & "', authorname = " & cboAuthor.DisplayMember & ", bookprice = " & txtBookPrice.Text & ", bookstocks = " & nudBookStocks.Text & ")", con)
            cmd.ExecuteNonQuery()

            MessageBox.Show("New book record saved!", "Book Save", MessageBoxButtons.OK, MessageBoxIcon.Information)

            disconnect()
        ElseIf NewRecord = False Then
            connect()
            cmd = New MySqlCommand("update products.books set bookname = '" & txtBookName.Text & "', bookprice = " & txtBookPrice.Text & ", authorname = " & cboAuthor.DisplayMember & ", bookstocks = " & nudBookStocks.Text & " where bookid = " & txtBookID.Text & "", con)
            cmd.ExecuteNonQuery()
            MessageBox.Show("Books record updated!", "Update Books", MessageBoxButtons.OK, MessageBoxIcon.Information)
            disconnect()
        End If
        clear()
    End Sub


and when i looked at the table it save's zeros(0)..can you help me?

Is This A Good Question/Topic? 0
  • +

Replies To: combobox

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10568
  • View blog
  • Posts: 39,127
  • Joined: 27-December 08

Re: combobox

Posted 11 October 2012 - 02:51 PM

Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1