Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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> )

  #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)

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

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