|
-
May 26th, 2010, 09:46 AM
#1
Thread Starter
Hyperactive Member
Help with deleting an MSAccess file in VB6.0
I have been searching trying to figure out the syntax for this but it escapes me.
I am adding records saving and retrieving no proble but how do I delete a record.
So far all I have seen in the Database using msAccess is the record marked #DELETED but is not really deleted. Here is my code.
I could really use some help with this
Thanks
Code:
Private Sub cmdDelete_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
Dim rs As New ADODB.Recordset
If MsgBox("Are you sure that you want to Deletet Record?", vbYesNo) = vbYes Then
rs.Open("DELETE FROM SDID1OrderDetail where OrderNumber = '" & cbstrCurrOrderNumber & "' and OrderLine = " & SDLI, strConn, 2, 2)
MsgBox("The Quote record has been deleted.")
'rs.Update()
rs = Nothing
HoldHighestSDLI = HoldHighestSDLI - 1
HighestSDLI = HighestSDLI - 1
If SDLI > 1 Then
SDLI = SDLI - 1
End If
ScreenUpDate()
txtDoorA.Text = SDLI
txtBaseDoorInfo.Text = "DOOR " & SDLI & " Base:"
txtBaseDoorInfo2.Text = "DOOR " & SDLI & " Base:"
Else
Exit Sub
End If
End Sub
-
May 26th, 2010, 10:34 AM
#2
Re: Help with deleting an MSAccess file in VB6.0
Are you sure you are using vb6?
The code looks like it is for vb.net (from the click event)
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 26th, 2010, 10:37 AM
#3
Re: Help with deleting an MSAccess file in VB6.0
Why are you opening a recordset to run a delete query? You are not returning records to the app so you should not be doing that. You write the SQL statement then execute it on the Connection/Command object combination.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
May 26th, 2010, 10:40 AM
#4
Thread Starter
Hyperactive Member
Re: Help with deleting an MSAccess file in VB6.0
Sorry this was a vb6.0 app upgraded to net. I do not want to change the way the DB connections are made and such. So I want to stay with the formats I know a little better.
-
May 26th, 2010, 10:41 AM
#5
Re: Help with deleting an MSAccess file in VB6.0
 Originally Posted by Alfarata
Sorry this was a vb6.0 app upgraded to net. I do not want to change the way the DB connections are made and such. So I want to stay with the formats I know a little better.
Try something like this... I typed this in notepad so please amend syntax errors if any...
Code:
Try
oConnOleDb = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb")
oConnOleDb.Open()
oCmdOleDb = New OleDbCommand("Delete from SDID1OrderDetail blah blah query",oConnOleDb)
If (oCmdOleDb.ExecuteNonQuery > 0) Then
MsgBox ("The Quote record has been deleted.")
End If
Catch ex As Exception
MsgBox(ex.Message.ToString(), MsgBoxStyle.Information)
Finally
oConnOleDb.Close()
End Try
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 26th, 2010, 10:43 AM
#6
Thread Starter
Hyperactive Member
Re: Help with deleting an MSAccess file in VB6.0
I keep seeing the references to why are you opening and to use and SQL statement, I guess I can't get the syntax correct I have tried many variations from the searchs but nothing is workig for me.
-
May 26th, 2010, 10:43 AM
#7
Re: Help with deleting an MSAccess file in VB6.0
 Originally Posted by Alfarata
Sorry this was a vb6.0 app upgraded to net.
Then don't use VB6 any more...use .NET
Don't use ADO any more...use ADO.NET
You are NEVER going to get comfortable in a .NET world if you insist upon walking using VB6 crutches.
Moved to VB.NET
I'll get you started. Here is how you would connect to your Access Database
vb.net Code:
Imports System.Data.OleDb
Public Class Form1
Private connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\database.mdb;"
Private conn As OleDb.OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection(connstring)
conn.Open()
End Sub
Last edited by Hack; May 26th, 2010 at 10:49 AM.
-
May 31st, 2010, 03:29 AM
#8
Lively Member
Re: Help with deleting an MSAccess file in VB6.0
hai,
Try this
UrConnection. Execute(" Delete * from urTable Where urConditions")
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
|