Results 1 to 4 of 4

Thread: Deleting records

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Does anyone know if it is possible to delete records
    from a record set opened with an SQL string? If i
    run this code it produces a runtime error:
    (3027 cannot update database or object is read only)
    but if i replace the SQL string with an actual table
    name the deletions take place and everything is fine.

    Private Sub cmdDelete_Click()
    Dim responce As String
    Dim strSql As String

    Set db = OpenDatabase(KeySetting)
    strSQL = strSql = "SELECT [Account Information].*, [Route Details].*, [Ticket Information].* FROM ([Account Information] INNER JOIN [Route Details] ON [Account Information].AccountID = [Route Details].AccountID) INNER JOIN [Ticket Information] ON ([Route Details].AccountID = [Ticket Information].AccountID) AND ([Account Information].AccountID = [Ticket Information].AccountID);"

    ' keysetting is just a public variable that contains the
    ' path from the GetSetting function.
    Set rs = db.OpenRecordset(strSql)
    responce = MsgBox("Are you sure that this record is to be deleted?", vbYesNo + vbQuestion)
    If responce = vbYes Then
    rs.Delete
    End If
    rs.Close
    End Sub

    ' I wanted to use cascading updates and deletes to make things easier but then i would have to force refrential integrity, which was causing an error.

    Thanks All........


  2. #2
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question Hmm...

    Have you tried running the SQL string as a stored procedure instead of letting VB do it?

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Can you do that? Well i guess ill have to break
    out my access book and give it a try.
    Thanks Bro....

  4. #4
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Lightbulb Hmm...

    If your have an access db, it might not work. But if you have a SQL db, I know that it will definitely work. If you have the money, you should buy this book(I have it as well):

    "Database Access with Visual Basic 6" by Jeffrey P. McManus. ISBN: 0-672-31422-3

    It has great examples, code, and talks about Jet databases as well as SQL databases. It costs approximately $40 but I got it for $27.99 at http://www.computerbooksexpress.com

    Hope this helps.

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