Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete with SQLEXEC????

Status
Not open for further replies.

JBonczek

Programmer
Apr 7, 2004
9
0
0
CZ
Hi all,

I have ODBC connection to a paradox table. I wont to delete one record but it doesn't work.

My code:

_connection1=sqlconnect('or32import')
cPar = import_n.name
_res=SQLexec(_connection1, 'delete from or32seznam where cislo = ?cPar')

Where is the problem???

This command work right:
_res=sqlexec(_connection1,'select * from or32seznam','cur_import')

Please help.
 
JBonczek,

Your code looks OK, assuming that cPar contains the correct value. In what way isn't it working? Do you see an error message? Or does the record simply fail to be deleted?

Have you tried putting a hard-coded value in the command, in place of ?cPar. That would tell you if it is your syntax that is at fault or something more fundamental.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
_res=SQLexec(_connection1, 'delete from or32seznam where cislo = ?cPar')

after this command _res = -1
I tried next command but the result was the same.

_res=SQLexec(_connection1, 'delete from or32seznam')
 
Hello JBonczek.

Try this instead:

Code:
_connection1=sqlconnect('or32import')
lcCommand = [delete from or32seznam where cislo = '] + ALLTRIM( import_n.name ) + [']
_res = SQLexec(_connection1, lcCommand )




Marcia G. Akins
 
JBonczek,

OK, after you run this code:

Code:
_res=SQLexec(_connection1, 'delete from or32seznam where cislo = ?cPar')

add the following:

Code:
if _res < 0
  AERROR(aErrorArray)
  messagebox(aErrorArray(2))
endif

That way, you'll see an error message that tells you exactly what went wrong. It might be an invalid column name, invalid table name, lack of permission, or one of many other things. Once you've seen the message, you can set about fixing it.

Mike



Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Also, int that way, the cPar variable needs to be PUBLIC or PRIVATE, but not the LOCAL

Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top