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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data grid in vb 1

Status
Not open for further replies.

ishikha

Programmer
Mar 22, 2002
36
IN
hi,

i am having a problem .i want to delete the record in between the data grid.i am using adodc control.
i am sending the code:


Private Sub delete_Click()
DataGrid1.AllowDelete = True
DataGrid1.AllowUpdate = True
If AdoRs.EOF Then
MsgBox "No more records in the file", , ""
Exit Sub
End If
AdoRs.delete

If Not AdoRs.EOF Then
AdoRs.Update
AdoRs.MoveNext
End If
DataGrid1.Refresh
End Sub

by using this code i am able to delete the first record in the database everytime but i want that as i select some record in between the datagrid with the record selector and press delete it will delete that record from the database


i have also tried the code:


Private Sub delete_Click()
Dim vBm As Variant
If DataGrid1.ApproxCount > 0 Then
For Each vBm In DataGrid1.SelBookmarks
AdoRs.Bookmark = vBm
AdoRs.delete
AdoRs.Update
Next
End If
DataGrid1.Refresh
End Sub

but in that case it gives the error in case of bookmark property of adodc
"this operation is not supported by the provider"

i am using the provider microsoft jet 3.51 provider

can u suggest me the sol.


regards
ishikha
 
ur first peice code should work fine...
in datagrid whenever u select a row & highlight.. the record pointer points the selected row. So, when u say delete the current selected record is deleted..

On top u have said u r using ADODC. then how can u write AdoRs.delete, this works for ADODB Recordset which is made thru code

If u binding a ADODC to the Grid, u have to give..
AdoRs.Recordset.Delete

u can personally contact me on rohan_powle@hotmail.com & be more specific about ur problem.. ______________________________
- Regards Rohan (India,Mumbai)
 
hi friends,

can u tell me how to add new record in between the data grid
i am sending the code:

Private Sub add_Click()
DataGrid1.AllowAddNew = True
DataGrid1.AllowUpdate = True
On Error GoTo 11
If AdoRs.BOF Then
DataGrid1.SetFocus
SendKeys "{home}+{down}"
Exit Sub
Else
Adodc1.Recordset.AddNew
AdoRs.MoveLast
DataGrid1.SetFocus
SendKeys "{down}"
Exit Sub
11:
MsgBox Err.Description
End If
End Sub

by this i can only able to add the new record at the end

can u tell me how i will be able to do it???????


regards
ishikha

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top