Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Avish

New Member
Registered:
Posts: 1
Reply with quote  #1 
Hi Can someone please assist with a Syntax error 'S'

Time:2012/11/08 03:02:31 PM

Project or Library Name:

Stage Name:

Form Name:UpdateJobScheduler

Component Type:

Description:Exception 'Incorrect syntax near 'S'. Unclosed quotation mark after the character string ')'.' occurred when attempting to 'Run script'.

FolderID:0900000000000000000000000004599

Process Name:

Action Name:InitiateJobsUpdate

Field Name:

Property Name:

Status Code:2



Details:Exception 'Incorrect syntax near 'S'. Unclosed quotation mark after the character string ')'.' occurred when attempting to 'Run script'. Incorrect syntax near 'S'. Unclosed quotation mark after the character string ')'.



SCRIPT USED BELOW:

#region

 

Using Statement

using

 

System;

using

 

System.Data;

using

 

System.Collections.Generic;

using

 

Metastorm.Ide.Extensibility;

using

 

Metastorm.Runtime.Core;

using

 

Metastorm.Runtime.Types;

using

 

System.ComponentModel;

using

 

System.Data.SqlClient;

#endregion

 

Using Statement

//Change this to a namespace that will suit you

namespace

 

Metastorm.Runtime.Models.ERPExtractionProject

{

///

<summary>

///

This needs to be a class or an interface that will support public, static methods/properties

///

</summary>

publicclass

ProcessDataScript

{

 

//Global Variables

publicstaticstring metastormConnectionString = "user id=bpm;password=MET@$torm;server=UECZASQL01;database=Metastorm;connection timeout=30"

;

publicstaticstring sysproAConnectionString = "user id=SysproODBC;password=ODBCisME;server=UECZAERP01;database=SysproCompanyA;connection timeout=30"

;

publicstaticstring sysproBConnectionString = "user id=SysproODBC;password=ODBCisME;server=UECZAERP01;database=SysproCompanyB;connection timeout=30"

;

 

//Update Jobs Table

[Promote(PromotionTargets.VisualToolbox)]

[Category(

"Syspro"

)]

[Alias(

"Update Metastorm Jobs Table"

)]

publicstaticvoid

updateJobs() {

SqlConnection sysproAConnection =

new

SqlConnection(sysproAConnectionString);

SqlConnection sysproBConnection =

new

SqlConnection(sysproBConnectionString);

sysproAConnection.Open();

sysproBConnection.Open();

SqlCommand aJobs =

new SqlCommand("select Job, JobDescription from WipMaster where Complete like 'N' and (WipCtlGlCode LIKE '90149' or WipCtlGlCode LIKE '90147' )"

,sysproAConnection);

SqlDataReader readSysproA = aJobs.ExecuteReader();

SqlCommand bJobs =

new SqlCommand("select Job, JobDescription from WipMaster where Complete like 'N' and (WipCtlGlCode LIKE '90149' or WipCtlGlCode LIKE '90147' )"

,sysproBConnection);

SqlDataReader readSysproB = bJobs.ExecuteReader();

 

string

theJob;

string

theDesc;

 

SqlConnection MtsmConnection =

new

SqlConnection(metastormConnectionString);

MtsmConnection.Open();

 

SqlCommand delAmmJobs =

new SqlCommand("Delete from ammJobs"

,MtsmConnection);

delAmmJobs.ExecuteScalar();

 

while

(readSysproA.Read()) {

theJob = (

string)readSysproA["Job"

];

theDesc = (

string)readSysproA["JobDescription"

];

SqlCommand updA =

new SqlCommand("Insert into ammJobs (Number, Description, Company) VALUES ('"+theJob+"', '"+theDesc+"', 'B')"

,MtsmConnection);

//SqlCommand upd = new SqlCommand("Insert into ammJobs (Number, Description, Company) VALUES ('sdfg', 'sdfgg', 'A')",MtsmConnection);

updA.ExecuteScalar();

}

//end while

while

(readSysproB.Read()) {

theJob = (

string)readSysproB["Job"

];

theDesc = (

string)readSysproB["JobDescription"

];

SqlCommand updB =

new SqlCommand("Insert into ammJobs (Number, Description, Company) VALUES ('"+theJob+"', '"+theDesc+"', 'A')"

,MtsmConnection);

//SqlCommand upd = new SqlCommand("Insert into ammJobs (Number, Description, Company) VALUES ('sdfg', 'sdfgg', 'A')",MtsmConnection);

updB.ExecuteScalar();

}

//end while

 

MtsmConnection.Close();

readSysproA.Close();

readSysproB.Close();

sysproAConnection.Close();

sysproBConnection.Close();

}

//end function

 

}

}

0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #2 
You should use the provided SelectSql() function. It looks like you are reinventing a wheel that has been provided for you, and that works much better.

The reason is you are using concatenated strings to build your SQL instead of parameters as you should, and one of the strings has a quote in it.

This post should also be in the version 9 forums. I'll move it soon.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!