Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello there

I have a following statement in sql if i run it int sql query anylizer its work properly. I want to execute it in my vb6 project. Means how can i execute following statement in vb6.

SQL
declare @txnno int
set @txnno = 1
UPDATE toll_veh_out SET @txnno = txn_no = @txnno + 1 where shift_date = '2012-11-01' and out_plaza_id = 1 and booth_no = 13


thank you in advance
Posted
Updated 1-Jan-13 1:57am
v2

This is a waste of time. Your variable is lost as soon a the SQL statement ends, so there's no value in setting it. You can remove it from your code. Just do set txn_no = txn_no + 1.

Also, VB6 is rubbish, no-one uses it, it's been obsolete for a decade. You're wasting your time learning it.
 
Share this answer
 
Try this..

VB
Dim CN As New ADODB.Connection
Dim cmd As New ADODB.Command

''' Connect your database connection
CN.Open "Connection String"

With cmd
    .ActiveConnection = CN ' set the connection object
    .CommandType = adCmdStoredProc ' set the stored procedure command type
    .CommandText = "UpdateTable"  ' set the name of stored procedure
    .Execute                       ' execute the sql statement in stored procedure
End With
Set cmd = Nothing
CN.Close
Set CN = Nothing
 
Share this answer
 

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