Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 18th, 2008, 04:25 AM
Authorized User
Join Date: Jun 2006
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Execute Stored Procdure from Javascript(JS) file

How to get a scalar value output by Executing a SQL Server's Stored Procdure from Javascript(JS) file.
 Although there are some examples on internet with Server object i.e
 but i m seeing the error "Server is undefined". If i put this code on a web page (e.g aspx - asp.net 2.0 ) then it will work fine. But my requirement is to Execute this code from JS file.
(JS file is called by an HTML page via a Script tag.
<script type="text/javascript" src="myFile.js"></script> )

Reply With Quote
  #2 (permalink)  
Old March 18th, 2008, 06:39 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

If you want to use a client-side script to execute a stored procedure then it's possible but unusual. You'd have to be able to create ActiveX on the client (or use a Java applet).
You can use:
var oConn = new ActiveXObject("ADODB.connection");
then set the connection string etc. I have done this in the past on a company intranet when for some reason server-side scripting was not possible but it can leave your SQL Server open to attack as anyone can read the connection string and use the information to connect directly.


Joe (Microsoft MVP - XML)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run a .js file from a javascript function sbkumar Javascript How-To 1 July 11th, 2008 11:12 AM
To include a js file into another js file jdang67 Javascript 4 February 28th, 2008 03:32 AM
Execute Stored Procedure from VBA Romashka Access VBA 1 February 22nd, 2007 12:52 PM
asp file into a javascript file (js)? jstewie Javascript How-To 2 August 25th, 2005 08:32 AM

All times are GMT -4. The time now is 11:01 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.