Greetings.

I've hunted around quite a bit on this one. There seem to be as many potential solutions as there are folks who have asked the question. I'm rewriting a vb6 app in .net and rather than use the conversion process i felt that the app could do with a complete redesign

I have an access database being displayed by a datagrid in vb.net 2003. Works fine I can search and sort and edit and add but i can't delete.

Dim mySurname As String        
        mySurname = txt_SearchSurname.Text & "%"
        OleDbDataAdapter1.SelectCommand.Parameters("SURNAME").Value = mySurname

        DataSet21.Clear()
        OleDbDataAdapter1.Fill(DataSet21)

.

I can update rows in the datagrid and update the database with

OleDbDataAdapter1.Update(DataSet21)

I can add new rows and get them added in the database but as for deleting i'm stuck.

I would appreciate help to get a simple way to add delete functionality.

Thanks

Greetings.

I have managed to get it working. I'm indebted to arjunsasidharan who posted some help to another member.

Not sure if it is the "correct" way or if there is a better way but it seems to work.

Is there a better way of refreshing the datagrid after the row has been deleted in the underlying database.

I've just cleared the datagrid and reloaded it

DBConn = New OleDb.OleDbConnection("Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
                "ocking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Program Files\Skimail" & _
                "\NZSKIMAIL.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transact" & _
                "ions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:S" & _
                "FP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Passwo" & _
                "rd=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compac" & _
                "t=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:E" & _
                "ncrypt Database=False")
        ln_CurrentTrakID = DataGrid1.Item(ln_CurrentRowNumber, 43)

        DBDelete.CommandText = "Delete From NZDATA Where  TRAKIDreal = " & Trim(Str(ln_CurrentTrakID))
        DBDelete.Connection = DBConn
        DBDelete.Connection.Open()
        DBDelete.ExecuteNonQuery()
        DBConn.Close()

        DataSet21.Clear()
        OleDbDataAdapter1.Fill(DataSet21)

Cool, thanks for following up with that.

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.