Hello all,

Im currently doing a project which is a system that adds booking records to it

it loads the database from a module

Set Db = OpenDatabase(App.Path & "\cihansol.mdb")
Set RS_Staff = Db.OpenRecordset("EPHS_Staff")
Set RS_Customers = Db.OpenRecordset("EPHS_Customers")

im very new to visual basic so i dont know much

anyway i did this

Dim Db As Database
Public RS_Staff As Recordset
Public RS_Customers As Recordset

so when you add info to the fields and click add it goes


Private Sub Command1_Click()
RS_Customers.AddNew
With RS_Customers
.Fields("F_Name") = Text1.Text
.Fields("S_Name") = Text2.Text
.Fields("Address") = Text3.Text
.Fields("Town") = Text4.Text
.Fields("Postcode") = Text5.Text
.Fields("Telephone") = Text6.Text
.Update
End With
Unload Form4
End Sub

Now i got another form that lists the records

RS_Customers.MoveFirst
'RS_Customers.Name
Do Until RS_Customers.EOF
    tmp = RS_Customers.Fields("unique_id")

    List1.ListItems.Add , tmp & "a", RS_Customers.Fields("S_name") & "," & RS_Customers.Fields("F_name")
    List1.ListItems(tmp & "a").SubItems(1) = RS_Customers("Address")
    List1.ListItems(tmp & "a").SubItems(2) = RS_Customers("Town")
    RS_Customers.MoveNext
Loop

I need a code that once u select a field and click delete it removes it from the database.


Thankyou

hello,
I can help you if you are using sql as database.
you want to delete a field from vb.net.

try this...

Dim cmd As New SqlCommand("delete from login where(userid='" + textbox1.Text + "')", c.con)
cmd.ExecuteNonQuery()

(c is object of class and con is object of connection)
userid is my column name in sql table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.