G
Guest
Hi,
I have a databound Combo Box where I'm adding a new value to the database on
the Click of the button. I'm able to see the ComboText and it is writing to
the database. But when I do a refresh on the Combo I'm not able to see the
added value in the Combo.
Please assist. Below is the code where I'm adding the new value to the Combo.
---------------
Dim txtmodelname As String
txtmodelname = InputBox("Please select the model name")
cmbModel.Text = txtmodelname
Dim con As OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand
Dim da As OleDbDataAdapter
Dim sConStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\db1.mdb"
Dim sqlStr As String = "Insert into Names (Name,Description,TypeId)
values (?,?,1)"
con = New OleDbConnection(sConStr)
cmd.Connection = con
'MsgBox(sqlStr)
cmd.Parameters.Add("Name", txtmodelname)
cmd.Parameters.Add("Description", txtmodelname)
cmd.CommandText = sqlStr
con.Open()
cmd.ExecuteNonQuery()
con.Close()
I have a databound Combo Box where I'm adding a new value to the database on
the Click of the button. I'm able to see the ComboText and it is writing to
the database. But when I do a refresh on the Combo I'm not able to see the
added value in the Combo.
Please assist. Below is the code where I'm adding the new value to the Combo.
---------------
Dim txtmodelname As String
txtmodelname = InputBox("Please select the model name")
cmbModel.Text = txtmodelname
Dim con As OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand
Dim da As OleDbDataAdapter
Dim sConStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\db1.mdb"
Dim sqlStr As String = "Insert into Names (Name,Description,TypeId)
values (?,?,1)"
con = New OleDbConnection(sConStr)
cmd.Connection = con
'MsgBox(sqlStr)
cmd.Parameters.Add("Name", txtmodelname)
cmd.Parameters.Add("Description", txtmodelname)
cmd.CommandText = sqlStr
con.Open()
cmd.ExecuteNonQuery()
con.Close()