Click here to Skip to main content
16,017,881 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have query in sql vb6.0 which is shown below:

loCon.Execute "Exec('kill " & rsa("spid") & "')"

when i wrote same query in c++ it is giving me a issue as

DB_E_ERRORSINCOMMAND One or more errors occurred during processing of command

could you please let me know what might be the issue or whether i have to update the query for c++

What I have tried:

Exec('kill(51)')

Exec('kill(52)')
Posted
Updated 4-May-18 6:31am
Comments
Maciej Los 4-May-18 17:38pm    
What returns: rsa("spid")?
Member 13655759 7-May-18 1:54am    
value like 51

Taken this is SQL Server, KILL command does not use parenthesis, Have a try with
SQL
Exec('kill 51')

Another this is that depending on the library you use, it may or may not require EXEC for the call. So if the problem still remains, try executing the command simply as
SQL
kill 51
 
Share this answer
 
Comments
Maciej Los 4-May-18 17:50pm    
5ed!
Member 13655759 7-May-18 1:55am    
i tried its not working
Wendelius 7-May-18 11:23am    
What happens, do you get an error message? If you do, what does it say?
The SQL commands are not identical:
SQL
-- VB
EXEC('kill id')
-- C++
EXEC('kill(id)')
Just use the same (correct) syntax as in your VB code by passing the id parameter separated with a space instead of enclosed by parentheses.
 
Share this answer
 
Comments
Maciej Los 4-May-18 17:49pm    
Well, it's not a matter of VB or c++, it's SQL issue.
I my opinion, first statement is correct. A second one - is not.
Jochen Arndt 5-May-18 2:33am    
That is what I tried to tell him by showing the used SQL commands together for comparison ("did you see your error now"?). I even told him to use the correct syntax without parentheses.
Member 13655759 7-May-18 1:55am    
i tried its not working
Jochen Arndt 7-May-18 2:53am    
What have you tried?
Are there any error messages?

Note also that the solutions are just examples. You have to pass a valid ID.

Depending on the used database and the db interface you might also try to get the full SQL error message. That will be more informative.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900