Help... deleting item from listbox & database

gen23
04-17-2004, 04:55 AM
Hi,

How can I delete an item from the listbox and database at the same time? For example: If I delete apple from the listbox, it should also be deleted from my database.

Shurik12
04-17-2004, 06:57 AM
Hi,

After you have selected the Listbox item do:
(assuming you have an ADO connection opened)

oConn.Execute "Delete * From Table1 Where Field1= '" & List1.Text & "'"
List1.RemoveItem (List1.ListIndex)



Shurik.

gen23
04-18-2004, 11:18 PM
Thanks... I'll do it... :)

gen23
04-22-2004, 11:40 PM
Thanks to all your help I was finally able to run the program, so here's the code that I've used:

Dim adoRs As ADODB.Recordset
Dim adoCn As ADODB.Connection

Set adoCn = New ADODB.Connection
Set adoRs = New ADODB.Recordset

adoCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "dbnames.mdb"
adoRs.Open "Table1", adoCn, adOpenKeyset, adLockOptimistic

adoCn.Execute "Delete * From Table1 Where names= '" & List1.Text & "'"
List1.RemoveItem List1.ListIndex

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum