Hi VictorJOL,
I use the next code to connect with the database and load the listbox
control with the data of this db. (I connect, bind the data and disconnect)
Dim strConexion As String
Dim objConexion As OleDbConnection
Dim objComando As OleDbDataAdapte r
Dim objDS As New DataSet
strConexion = "PROVIDER=MICRO SOFT.JET.OLEDB. 4.0;" & "DATA SOURCE=" &
"C:\Ejemplo.mdb "
objConexion = New OleDbConnection (strConexion)
objComando = New OleDbDataAdapte r("Select * From Tabla", strConexion)
objComando.Fill (objDS, "Ejemplo")
Dim Row
Dim Fila As DataRow
'intContador = 1
ListBox1.Items. Clear()
For Each Row In objDS.Tables("E jemplo").Rows
ListBox1.Items. Add(Row(0))
Next
objConexion.Clo se()
Later, I remove an element of the listbox control, but the connection with
the db, is switch off.
ListBox1.Items. RemoveAt(2)
I hope that helps.
Kind Regards,
Jorge Serrano Pérez
MVP VB.NET
"VitorJOL" wrote:
Hello
I have a listbox with a datasource.I want to remove a row from listbox but
not remove it from the database.
How can i do this ?
PROBLEM:"Cannot modify the Items collection when the DataSource property is
set."