Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to refresh my combobox

$
0
0
Hi. This is my first post to this forum. I've read the rules, written before asking the question in multicolor fashion. some were not picked by my mind but if any mistake then please guide me.


I've a form on which i have a combobbox, in which at the form load even and submit button click event, the items are loaded from the table right. its also enabled with AutoComplete option. So, when i insert the new entry in combobox, so it does not appear, until i close the form and re-open it.
This is my code
 Dim insProd As String = "insert into ProdInfo (Prod_Name, Prod_Pri, Prod_Desc, Prod_Made) values (@Prod_Name, @Prod_Pri, @Prod_Desc, @Prod_Made)"
        Dim cmdSql As New SqlCommand(insProd, cnSql)
        cmdSql.CommandType = CommandType.Text
        daSql.InsertCommand = cmdSql

        With cmdSql

            .Parameters.Add("@Prod_Name", SqlDbType.VarChar).Value = cmbProdName.Text.Trim
            .Parameters.Add("@Prod_Pri", SqlDbType.Int).Value = txtProdPri.Text.Trim
            .Parameters.Add("@Prod_Desc", SqlDbType.VarChar).Value = txtProdDesc.Text.Trim
            .Parameters.Add("@Prod_Made", SqlDbType.VarChar).Value = txtProdMade.Text.Trim

        End With

        cnSql.Open()
        cmdSql.ExecuteNonQuery()
        cnSql.Close()

        MsgBox("Record Inserted Successfully", MsgBoxStyle.OkOnly, "Product Inserted")
        Clear(Me)
        ClearCombo(Me)
        cmbProdName.Focus()


        Dim selProd As String = "select * from ProdInfo"
        Dim cmdSql1 As New SqlCommand(selProd, cnSql)
        cmdSql1.CommandType = CommandType.Text
        daSql.SelectCommand = cmdSql1

        daSql.Fill(dsSql, "ProdInfo")

        Dim s As Integer
        For s = 0 To dsSql.Tables("ProdInfo").Rows.Count - 1
            cmbProdName.Items.Add(dsSql.Tables("ProdInfo").Rows(s).Item(1))
        Next


Please guide me that why it does not show the value, right after the buton click event.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>