Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a record + dbclick on a datagrid = error

Status
Not open for further replies.

RSX02

Programmer
May 15, 2003
467
CA
Hi
I have a datagrid in a form. When I double click in it that bring my data in textboxes. When I press the delete button it delete my record. that's working fine.

When I double click in my datagrid once my record is deleted, if I double click on a record that was above the record that I deleted, that's working fine. But if I double click on a record that was after the record that I just deleted, that make an error that says that I try to select a record that is deleted....

?!?
Thanks in advance
 
Need to see code to understand what methods you're using.

You probably need to remove the row from the datagrid as well as removing the record from the database.

 
Private NoSeq As Integer

when I press the button delete:
Dim Answer As String
If NoSeq <> 0 Then
Answer = MsgBox(&quot;Are you sure you want to delete this record?&quot;, MsgBoxStyle.YesNo, &quot;Delete&quot;)
If Answer = 6 Then
Dim dr As DataRow
dr = m_DataLayer.DsOwner.Owners.Rows.Find(NoSeq)
dr.Delete()

Me.First_Name.Text = String.Empty
Me.Last_Name.Text = String.Empty

Me.NoSeq = 0
End If
DatasetOwners1.Merge(m_DataLayer.DsOwner)

Me.DataGrid1.Refresh()
End If

when I double click on my datagrid:

Dim dr As DataRow

dr = m_DataLayer.DsOwner.Tables(&quot;Owners&quot;).Rows(DataGrid1.CurrentRowIndex)

If Not (dr.IsNull(&quot;First_Name&quot;)) Then
Me.First_Name.Text = dr(&quot;First_Name&quot;)
Else
Me.First_Name.Text = &quot;&quot;
End If
If Not (dr.IsNull(&quot;Last_Name&quot;)) Then
Me.Last_Name.Text = dr(&quot;Last_Name&quot;)
Else
Me.Last_Name.Text = &quot;&quot;
End If
If Not (dr.IsNull(&quot;Seq&quot;)) Then
Me.NoSeq = dr(&quot;Seq&quot;)
Else
Me.NoSeq = 0
End If
 
Please...
I really need help on this.
I would really appreciate any idea.
I tried many things and I didn't find something that could help me. I guess that it's just because I'm new with VB.Net and I use datalayer that it is not use often as I can see on the web.
 

If there isn't alot of data, you could reload the datagrid after deleting the record.
 
ok
I still have the same probleme here...I had to pass to others problems before and then, I'm back with this one.
Could somebody help me. here is the code of my delete button:

Dim Answer As String
If NoSeq <> 0 Then
Answer = MsgBox("Are you sure you want to delete this record?", MsgBoxStyle.YesNo, "Delete")
If Answer = 6 Then
Dim dr As DataRow

dr = m_DataLayer.DsContractor.Contractors.Rows.Find(NoSeq)
dr.Delete()

Me.First_Name.Text = String.Empty
Me.Last_Name.Text = String.Empty
Me.Address_1.Text = String.Empty
Me.Address_2.Text = String.Empty
Me.Address_3.Text = String.Empty
Me.Address_4.Text = String.Empty
Me.Address_5.Text = String.Empty
Me.City.Text = String.Empty
Me.State.Text = String.Empty
Me.Zip.Text = String.Empty
Me.Country.Text = String.Empty
Me.Firm.Text = String.Empty
Me.Phone.Text = String.Empty
Me.Mobile.Text = String.Empty
Me.Fax.Text = String.Empty
Me.Email.Text = String.Empty
'Else
Me.NoSeq = 0
End If
DatasetContractors1.Merge(m_DataLayer.DsContractor)
Me.DataGrid1.Refresh()
End If

thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top