Results 1 to 13 of 13

Thread: sql RS.delete event help (error runtime 214746259)(RESOLVED)

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved sql RS.delete event help (error runtime 214746259)(RESOLVED)

    I use ADO to access SQL table as database and I have problem when objRS.delete is access. This command is to remove all record in the table.

    "Error run time 214746259(80004005)
    Key column information is insufficent or incorrect.Too many row were infected by update"

    when use in Access table is run smootly.I dont know what's up here. If any ever experiences and know exactly what's up here can give comment is greatly appreciated.thanks in advance
    VB Code:
    1. Dim objConnection As ADODB.Connection
    2. Dim objRS As ADODB.Recordset
    3.  
    4. Private Sub Command3_Click()
    5.  
    6. If objRS.RecordCount = 0 Then
    7.     MsgBox "OUW. NO RECORD!"
    8.     Exit Sub
    9. Else
    10. objRS.MoveFirst
    11.  
    12. Do While Not objRS.EOF
    13.     objRS.MoveFirst
    14.     [B]objRS.Delete[/B]
    15.     objRS.Update
    16.    
    17.     objRS.MoveNext
    18. Loop
    19.     MsgBox "Finish,Hm"
    20. End If
    21. End Sub
    Best Regards
    Kamus
    Last edited by ksuwanto8ksd; Jun 11th, 2005 at 01:05 AM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: sql RS.delete event help (error runtime 214746259)

    The code below should do it....

    VB Code:
    1. objConnection.Execute "DELETE * FROM TableName"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: sql RS.delete event help (error runtime 214746259)

    hi dee-u

    run time error 2147217900
    incorect syntax near '*'

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: sql RS.delete event help (error runtime 214746259)

    TableName is the name of your table.... Are you using SQL Server?

    VB Code:
    1. objConnection.Execute "DELETE FROM TableName"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: sql RS.delete event help (error runtime 214746259)

    "run time error 2147217864980040e38)
    Row cannot be located for updating.Some value may have been changed since it was last read"

    error line "objRS.delete"

  6. #6
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: sql RS.delete event help (error runtime 214746259)

    Quote Originally Posted by ksuwanto8ksd
    "run time error 2147217864980040e38)
    Row cannot be located for updating.Some value may have been changed since it was last read"

    error line "objRS.delete"
    Replace your Command3 event procedure with this two lines of code.

    VB Code:
    1. Private Sub Command3_Click()
    2.     ''Assuming Table1 is the name of table to which objRS is connected
    3.     objConnection.Execute "DELETE FROM Table1"
    4.     objRS.Requery
    5. End Sub

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  7. #7

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: sql RS.delete event help (error runtime 214746259)

    ouw , nice .run smootly ,thanks

  8. #8

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: sql RS.delete event help (error runtime 214746259)

    hi Pradeep

    What objRS.Requery is doing here? extra regards

    best regards

  9. #9
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: sql RS.delete event help (error runtime 214746259)

    I think this should suffice even without the requery...

    VB Code:
    1. Private Sub Command3_Click()
    2.     ''Assuming Table1 is the name of table to which objRS is connected
    3.     objConnection.Execute "DELETE FROM Table1"
    4. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  10. #10
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: sql RS.delete event help (error runtime 214746259)

    Quote Originally Posted by dee-u
    I think this should suffice even without the requery...

    VB Code:
    1. Private Sub Command3_Click()
    2.     ''Assuming Table1 is the name of table to which objRS is connected
    3.     objConnection.Execute "DELETE FROM Table1"
    4. End Sub
    Sorry, but It won't,
    The requery statement will clear the recordset.
    Otherwise,
    The records will still be in the recordset, though deleted from database. So whenever he tries to access them again, he will get an error.
    The error which he is getting is just due to the reason that some records have already been deleted/modified from some other part of the app and so it can't be deleted here again. They are already not in the database.

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  11. #11
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: sql RS.delete event help (error runtime 214746259)

    Hmmmmnnnnnn......

    Will this cause an error?

    VB Code:
    1. Private Sub Command3_Click()
    2. Dim objRS As ADODB.Recordset
    3. ''Assuming Table1 is the name of table to which objRS is connected
    4. objConnection.Execute "DELETE FROM Table1"
    5. set objRS = New ADODB.Recordset
    6. objRS.Open "SELECT * FROM Table1",objConnection
    7. End Sub

    I dont have vb in this computer right now to check it but I have not used .Requery when I delete from a database.... And isnt it that objConnection is a Connection object and not a Recordset object, therefore whats the use of requery in it?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  12. #12

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: sql RS.delete event help (error runtime 214746259)(RESOLVED)

    Yes it clear the reordset. and when I use if ...else event it realy help

    Thanks for all response

  13. #13

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: sql RS.delete event help (error runtime 214746259)(RESOLVED)

    dee-u your code do delete recordset from table and database too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width