• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 127
  • Last Modified:

Deleting a record in a .db database

Hi,

I am writing records from a .db database to sql database.
What i am trying to do now, is i am reading certain fields from the sql database and in return i am trying to delete a record on my machine in delphi.

This was the code i was trying to use, but gives and error, but doesn't specify what is wrong
EliteDB.Execute "DELETE * FROM Batch_de where " & """" & "Batch Number" & """" & " = " & WBBatchNumber & ""

Can someone help with this, please!
0
mscala
Asked:
mscala
1 Solution
 
watyCommented:
EliteDB.Execute "DELETE * FROM Batch_de where " & """" & "Batch Number" & """" & " = " & WBBatchNumber & ""

Could you post a sample query?

It seems that you query will be something like
DELETE * FROM Batch_de where "Batch Number" = AZER

You code should be this
EliteDB.Execute "DELETE * FROM Batch_de where Batch Number = """ & WBBatchNumber & """"

or
EliteDB.Execute "DELETE * FROM Batch_de where Batch Number = " & WBBatchNumber

if WBBatchNumber is a numeric
0
 
mscalaAuthor Commented:
This is the code i am running
I tried something different, but still doesn't work

SqlWriteBatch = "DELETE * FROM Batch_de where " & """" & "Batch Number" & """" & " = " & WBBatchNumber & ""
                        RsWriteBatch.Open SqlWriteBatch, EliteDB, adOpenStatic, adLockOptimistic, adCmdText
EliteDB.Execute SqlWriteBatch

Your two statements, give the error "syntax error (missing operator)in query expression BatchNo = 1

???

0
 
Éric MoreauSenior .Net ConsultantCommented:
Give this a try (the * is removed and the field name is between square brackets):

EliteDB.Execute "DELETE FROM Batch_de where [Batch Number] = " & WBBatchNumber
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now