Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VBScript Syntax Error

Posted on 2006-05-04
9
Medium Priority
?
186 Views
Last Modified: 2010-04-07
Can someone tell me where my syntax is incorrect in this line...

The error I get says its  Incorrect syntax near 'BC' the only place in the string it has a BC is in the KEYWORD so I am not sure what I am doing wrong...

objADOCnn.Execute "UPDATE MLB_Schedule_Log SET STORYNUMBER='"& r1 &"',SELECTORCODE='"& r2 &"',VERSION='"& r4 &"',DATE='"& r5 &"',WORDCOUNT='"& r6 &"',DATETIME='"& r7 &",LEAGUE='"& r8 &"'WHERE KEYWORD='"& r3 &"'"
0
Comment
Question by:jsuttor
9 Comments
 
LVL 3

Assisted Solution

by:fullcontact
fullcontact earned 400 total points
ID: 16606147
Try putting [] around your field names, date is a reserved word in SQL

objADOCnn.Execute "UPDATE MLB_Schedule_Log SET [STORYNUMBER]='"& r1 &"',[SELECTORCODE]='"& r2 &"',[VERSION]='"& r4 &"',[DATE]='"& r5 &"',[WORDCOUNT]='"& r6 &"',[DATETIME]='"& r7 &",[LEAGUE]='"& r8 &"'WHERE [KEYWORD]='"& r3 &"'"

Also make you if any of your variables contain a single quote you replace this with two single quotes
0
 
LVL 11

Assisted Solution

by:leclairm
leclairm earned 400 total points
ID: 16606267
Also, put a space between your last single quote and the where clause:

...
'"& r8 &"' WHERE KEYWORD=
...
0
 
LVL 3

Author Comment

by:jsuttor
ID: 16607044
Tried both of those suggestions and NOPE no go. The problem is in this part of the statement [KEYWORD]='"& r3 &"'".

R3 is where the BC is coming from..... The rest of the KEYWORD is BC-BBA-SCHD-MLBSKED.xml
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Author Comment

by:jsuttor
ID: 16607072
Oops Keyword is KEYWORD is BC-BBA-SCHD-MLBSKED without the .xml
0
 
LVL 3

Author Comment

by:jsuttor
ID: 16607479
[WORDCOUNT]='"& r6 &"',[DATETIME]='"& r7 &",

Problem is that I was missing a ' at the endof the datetime
0
 
LVL 3

Accepted Solution

by:
ddepastino earned 1200 total points
ID: 16610527
A function makes these easier to read/catch BTW:


MsgBox "UPDATE MLB_Schedule_Log SET [STORYNUMBER]=" & C39(r1) & _
", [SELECTORCODE]=" & C39(r2) & _
", [VERSION]=" & C39(r4) & _
", [DATE]=" & C39(r5) & _
", [WORDCOUNT]=" & C39(r6) & _
", [DATETIME]=" & C39(r7) & _
", LEAGUE]=" & C39(r8) & _
" WHERE [KEYWORD]=" & C39(r3)

End Sub
Private Function C39(ByVal DaString As String) As String
   C39 = Chr$(39) & DaString & Chr$(39)
End Function
0
 
LVL 3

Author Comment

by:jsuttor
ID: 16632717
yes putting in the a function would have made it easier to catch. Thanks for the suggestion. Since I figured out the answer to this question myself I am going to award points to everyone for helping me try to find a solution
0
 
LVL 3

Expert Comment

by:ddepastino
ID: 16632759
I think that if the Questioner provides the answer then the Answerers should provide the points.
Oh wait, I'm an Answerer, never mind.....
0
 
LVL 3

Author Comment

by:jsuttor
ID: 16632789
I agree to a certain extent if someone give you an answer that leads your thinking to an answer that should also be awarded points and I believe that all of your helped in the process of me figuring either a better way to do things or lead to me figuring out the solution.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question