Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
How to Execute a SQL Server's Stored Procdure from Javascript(JS)
Old 03-18-2008, 06:53 AM How to Execute a SQL Server's Stored Procdure from Javascript(JS)
Novice Talker

Posts: 10
Name: Muhammad Abrar
Trades: 0
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
Server.CreateObject("ADODB.connection")
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>
)
AbrarNazeer is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-18-2008, 09:14 AM Re: How to Execute a SQL Server's Stored Procdure from Javascript(JS)
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,526
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
javascript cannot "talk" directly to a SQL server
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-18-2008, 12:03 PM Re: How to Execute a SQL Server's Stored Procdure from Javascript(JS)
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
No, it cannot for security reasons. Javascript code is client-side, which means anyone can read it...including any parts related to connection to the database.

This could be done in AJAX, but not Javascript. How you do it depends on your setup, there are about a million answers, and you're not going to get one in this thread for what you're doing.

This, however, leads to a deeper problem...you seem to be overtrained in knowledge and undertrained in application and critical thinking. You need to do some studying up on what different languages can do and how they're to be used.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-18-2008, 02:37 PM Re: How to Execute a SQL Server's Stored Procdure from Javascript(JS)
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Scalar = 1 value, something that can fit into a variable that isn't a collection or an array. You can get the return value to javascript using a hidden input form field.

You can build an ASPX page that the javascript calls, and have that page execute your procedure and put the results in a hidden field.

Your database server shouldn't be reachable from just any random person's computer who's looking at your page. Forget SQL Injection - that only happens when a person can guess how your application works, and give just hte right input to trick it into running a query they want run. Imagine the fun that comes when people can just send any query they like directly, using javascript. Think

DECLARE @SQL VARCHAR(MAX)
SELECT @SQL = 'TRUNCATE TABLE ' + NAME FROM SYS.TABLES
EXEC (@SQL)

Bye bye all the data in your database.

Why would you ever want to let people talk directly to your SQL Server themselves?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to Execute a SQL Server's Stored Procdure from Javascript(JS)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21268 seconds with 12 queries