SQL string

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

SQL string

Post by pgriffin » Sat Jul 29, 2006 5:22 am

I am trying to pass two vars to a VBScript sub to change a numeric field which is a sequence.

something like

Code: Select all

Sub AssignSequence(cProc,cSeq)
    dim imgActDB
    dim SQLUpdate
    dim rsActions
    Set ImgActDB = CreateObject("ADODB.Connection")
    ImgActDB.Open "Provider = MicroSoft.JET.OLEDB.4.0; Data Source=c:\DB\DB.mdb;"
SQLUpdate = "Update Table set SeqNO= ((SeqNO + 10) where SequenceNbr > & cSeq & and ProcID = '" & cProc & "'))"
set rsActions = ImgActDB.Execute(SQLString)
End Sub

This code does NOT work.  I can select the correct records, but cannot change any of the sequence numbers.



User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jul 29, 2006 7:14 am

You've missed out a couple of quotes, where you are concatinating the cSeq variable with the string:

SQLUpdate = "Update Table set SeqNO= ((SeqNO + 10) where SequenceNbr > " & cSeq & " and ProcID = '" & cProc & "'))"
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sat Jul 29, 2006 8:30 pm

thanks Marcus.

I did have to tweak the code a bit more but you got me over that hurdle. Here is the final version.

SQLUpdate = "Update Table set SequenceNbr = SequenceNbr + 10 where (SequenceNbr > " & cSeq & " and ProcessID = '" & cProc & "')"

staring at code too many hours at a time these days....

thanks again...

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts