Forum Discussion
mspatel
9 years agoContributor
Hi ,
Thanks a lot. Do you happened to have code using all these function calls ?
tristaanogre
9 years agoEsteemed Contributor
Here's an example:
//The following function can be included in any project but it only ever needs to be run the first time to set up the desired settings
function SQLOptions(){
SQLUtilities.SetSQLType = 'MSSQL'; //Can be either MSSQL or MYSQL_351
SQLUtilities.SetSQLSecurityType = 'INTEGRATED'; //Can be either INTEGRATED or PROMPT
}
//Now, if I want to run an SQL query against my database where I log the street address for all addresses in Pennsylvania, USA
function getPAStreetAddresses() {
var mySQLQuery;
var myRecords;
SQLUtilities.DatabaseName = 'MyDatabase';
SQLUtilities.SQLServerName = 'MyServer';
SQLUtilities.SQLUserName = 'myusername'; //This is not necessary since I'm using integrated security. Provided in example to allow for editing and adaptation
SQLUtilities.SQLPassWord = 'mypassword'; //This is not necessary since I'm using integrated security. Provided in example to allow for editing and adaptation
mySQLQuery = SQLUtilities.NewSQLQuery('SELECT * FROM ADDRESSES WHERE STATE = :STATE and COUNTRY = :COUNTRY', {STATE: 'PA', COUNTRY: 'USA'}, false);
mySQLQuery.open();
myRecords = mySQLQuery.execute();
while (!myRecords.EOF) {
Log.Message('Street Address: ' + myRecords.Fields.Item('STREETADDRESS').Value);
myRecords.MoveNext();
}
mySQLQuery.closeAndNull;
}