Solved

How to call a stored procedure from a function

Posted on 2009-04-06
3
218 Views
Last Modified: 2013-11-24
Hi,

I'd like to know how / correct syntax I should be using to call a stored procedure in SQL Server from a script function in JavaScript.

The environment I'm working in is Sage CRM however the answer to this question does not appear to need to be specific to any particular software.

Thanks
0
Comment
Question by:TartanTaurus
  • 2
3 Comments
 
LVL 19

Expert Comment

by:elimesika
Comment Utility
0
 
LVL 1

Author Comment

by:TartanTaurus
Comment Utility
Thanks for that,

I have my connection as follows, but when I try to call it, I get an error saying it cannot find stored proc by that name. Any suggestions?

Thanks


function UpdateRecord()
 

{

var connection = new ActiveXObject("ADODB.Connection");

connection.Open("Data Source=localhost\\TabletProject,1433;Provider=SQLOLEDB;User Id=sa;Password=xxxxx;Persist Security Info=True;Initial Catalogue=G41;");
 

var r = connection.Execute("exec customrefproc");
 

oppo_customref = r; 

}

Open in new window

0
 
LVL 19

Accepted Solution

by:
elimesika earned 500 total points
Comment Utility
HI

Try using fully qualified name
connection.Execute("exec <your database>.dbo.customrefproc");

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now