Skip to content

Instantly share code, notes, and snippets.

@jpablobr
Created June 29, 2010 06:18
Show Gist options
  • Select an option

  • Save jpablobr/456860 to your computer and use it in GitHub Desktop.

Select an option

Save jpablobr/456860 to your computer and use it in GitHub Desktop.
function usp_ExternalSPROC(){
try {
var AConnection, Tbl, Field_NameR;
// Create a new Connection object
AConnection = ADO.CreateConnection();
AConnection.ConnectionString =
“Provider=SQLOLEDB.1;”+
“Persist Security Info=False;”+
“User ID=**User_Name**;”+
“pwd=**User_Pass**;”+
“Initial Catalog=**DataBase**;”+
“Data Source=**SQL_Instance**”;
Alright cool! Now that we have a valid connection string we should activate the connection.
AConnection.Open();
Here we are going to set “Tbl” to execute the SPROC using the “AConnection” that we created previously.
Tbl = AConnection.Execute(“[**DataBase**].[dbo].[usp_ExternalSPROC]“);
Then with the while loop we are scanning all the records till the End-of-file (EOF) and print the information on those fields.
// Scans all records returned by the SPROC
Tbl.MoveFirst();
while (!Tbl.EOF){
// Gets the field values from the ORDER BY
Field_NameR = Tbl.Fields(“Field_Name”).Value;
Log.Message(Field_NameR);
Tbl.MoveNext();
}
Finally we close the connection with the DB.
// Close connection
AConnection.Close();
}
catch(exception){
Log.Error(“Exception, exception”.description);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment