Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27064

VS 2005 why combobox is not updated with last entered value

$
0
0
Hi. This is my ProdInfo form Submit Button Code.
Quote:

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()



'' LOAD THE prodInfo INTO DATASET
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")


'' LOADING DATABASE ITEMS INTO COMBOBOX
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


'' DISPLAYING LAST ENTERED VALUE
Dim a, b As Integer
For a = 0 To dsSql.Tables("ProdInfo").Rows.Count - 1
b = dsSql.Tables("ProdInfo").Rows(a).Item(0)
Next
Label6.Text = "Last entry was" & " " & b
When i insert the full record and press the Submit button; the data is being inserted into Database right. the control get clear and the focus goes to the first control (cmbProdName), which is selected to AutoComplete Mode SuggestAppend and source is ListItem. What I want is that when i start new entry so the last inserted value is also displayed in the combobox, but its not displaying. Pleas assist me for this.

Viewing all articles
Browse latest Browse all 27064

Trending Articles



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