.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > How to Execute Stored Procdure from Javascript(JS)
 

How to Execute Stored Procdure from Javascript(JS)

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

Muhammad Abrar

You cannot execute a SQL Server store procedure from client-side code running in the browser.

You will need to postback to the server and have code in the ASPX page execute the stored procedure.

You shouldavoid usingServer.CreateObject in ASPX code. If you find example code for using Server.CreateObject it will be for Classic ASP not ASP.NET.

You absolutely should not use ADODB from with in .NET code. Use classes in System.Data.SqlClient to perform operations on SQL Server. Also review the SqlData controls in the System.Web.UI.WebControls namespace.

I would also suggest you take the time to run through some of the ASP.NET quickstarts and tutorials.

Anthony Jones

You cannot execute a SQL Server store procedure from client-side code running in the browser.

You will need to postback to the server and have code in the ASPX page execute the stored procedure.

You shouldavoid usingServer.CreateObject in ASPX code. If you find example code for using Server.CreateObject it will be for Classic ASP not ASP.NET.

You absolutely should not use ADODB from with in .NET code. Use classes in System.Data.SqlClient to perform operations on SQL Server. Also review the SqlData controls in the System.Web.UI.WebControls namespace.

I would also suggest you take the time to run through some of the ASP.NET quickstarts and tutorials.

Anthony Jones

You can use google to search for other answers

Custom Search

More Threads

• Window.open script error
• PopUp problem.
• Consuming Web Service in (Browser Independent)
• help on html to excel
• cannot right click-and-hold to select and copy HTML (ASPX) page displayed using window.showModalDialog()
• passing parameter from popup to parent
• WebControls TreeView looks different in IE than in FireFox
• How to load html table to the page not visible.
• Time Difference observed while using new Date() in Jscript.NET
• simplest way to call a javascript function from c#