Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL2000 VB6
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
Edited 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
0 OriginalGriff 443
1 Sergey Alexandrovich Kryukov 197
2 PhilLenoir 145
3 RyanDev 125
4 Richard Deeming 120
0 Sergey Alexandrovich Kryukov 6,415
1 OriginalGriff 5,856
2 CPallini 2,473
3 Richard MacCutchan 1,667
4 Abhinav S 1,530

Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2014
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