8 Replies - 184 Views - Last Post: 13 May 2019 - 12:12 PM Rate Topic: -----

#1 pigkrosano   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-May 19

delete row datagrid and savind to access database

Posted 13 May 2019 - 11:43 AM

The issue is to update the deleted row to the database. Once I run the program, it shows me that the selected row was deleted, but if I stop the program and run again, the row which was supposed to be deleted is still there. How could I save it? Thank you in advance


Dim index As Integer
con = New ADODB.Connection
        rs = New ADODB.Recordset
        tb = New DataTable
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\test.mdb;Persist Security Info=true"
        con.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        con.Open()
        rs.Open("table1", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, 2)

        index = gridPessoa.CurrentCell.RowIndex
        gridPessoa.Rows.RemoveAt(index)
        rs.Update()



Is This A Good Question/Topic? 0
  • +

Replies To: delete row datagrid and savind to access database

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 11:49 AM

Typically I just write the SQL DELETE query and provide the specific row key I want to remove. Straight forward and easy to follow.
Was This Post Helpful? 0
  • +
  • -

#3 pigkrosano   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-May 19

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 11:54 AM

I tried something like this, but still did not work :(

Dim index As Integer
Index = gridPessoa.CurrentRow.Index
Dim SQLCommand As String = "DELETE * FROM table1 WHERE ID = '" & index & "'"

rs.Update()


Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 11:57 AM

That's not well formed or all there.

You would want to declare a SQL command object, give it an open connection string and sql query.. provide the parameters to it.. then use the 'execute non query' on that object.
Was This Post Helpful? 0
  • +
  • -

#5 pigkrosano   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-May 19

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 12:01 PM

But, what if I want to delete the row just by selecting the row and then clicking in a button which would delete the data from access also. You know what I mean? what if I do not want to type the key to delete the profile
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 12:02 PM

Yeah.. that still works the same. How ever you get the actual row's key ID you pass it into a funciton that does the delete.
Was This Post Helpful? 0
  • +
  • -

#7 pigkrosano   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-May 19

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 12:05 PM

Honestly, I have no idea where to start it.
Could you help me to make it?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 12:07 PM

I'll pass on doing your work for you, but I am available for questions.

I have an old snippet that shows the components.
https://www.dreaminc...-command-setup/
Was This Post Helpful? 0
  • +
  • -

#9 pigkrosano   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-May 19

Re: delete row datagrid and savind to access database

Posted 13 May 2019 - 12:12 PM

thanks tho
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1