|
-
Oct 13th, 2000, 09:09 AM
#1
Thread Starter
Dazed Member
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........
-
Oct 13th, 2000, 01:22 PM
#2
Hyperactive Member
Hmm...
Have you tried running the SQL string as a stored procedure instead of letting VB do it?
-
Oct 13th, 2000, 01:35 PM
#3
Thread Starter
Dazed Member
Can you do that? Well i guess ill have to break
out my access book and give it a try.
Thanks Bro....
-
Oct 13th, 2000, 02:10 PM
#4
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|