Help Datagrid how to delete everything in it

dicky18

Member
Joined
Sep 22, 2005
Messages
23
Location
bangkok
Programming Experience
Beginner
Hi there i was hoping if someone could help me wiith my datagrid
i have an invoice so i add products to to the datagrid for example i have 3 products in it for this invoice when i save the invoice i need to delete these products from the product table im using access database
i thin we should use count or something coz sometimes we have 1,2,3,4,5..... products i want to delete them
thx in advance
 
re:

a is input to delete
VB.NET:
 If a <> "" Then
clear dataset.open connection.
give adapter the command text and fill the dataset
VB.NET:
            Me.DataSet11.Clear()
            Me.OleDbConnection1.Open()
            Me.OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM dbab where ID = " + a
            Me.OleDbDataAdapter1.Fill(DataSet11)


VB.NET:
'check if adapter found result from db and filled it in dataset  
          If (Me.BindingContext(DataSet11, "dbab").Count > 0) Then

'delete the record found
                Me.BindingContext(DataSet11, "dbab").RemoveAt(Me.BindingContext(DataSet11, "dbab").Position)

'update the database
                Me.OleDbDataAdapter1.Update(DataSet11)
            End If

            Me.OleDbConnection1.Close()
        End If
 
Back
Top