Click here to Skip to main content
13,042,421 members (82,806 online)
Rate this:
Please Sign up or sign in to vote.
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.

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 1-Jan-13 1:21am
Updated 1-Jan-13 1:57am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this..

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
Set CN = Nothing

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100