Mohammed Atef’s Technical blog

Calling DB from JS

Really I love Java Script .I was very happy to know how to retrieve data from database via JS.
kindly you can use the below Java Script code to retrieve information from ProcSP stored procedure.

var  connObj = Server.CreateObject(“ADODB.connection”);
connObj.Open(
“DRIVER={ SQL Server }; SERVER = 9.1.2.1;DATABASE=TEST”,“sa”,“xyz”);
var recordSetObj = Server.CreateObject(“ADODB.Recordset”);
var StrName = “val”;
var RetVal;
var query = “Exec ProcSP ‘”+StrName+“‘,'”+RetVal+“‘”;
recordSetObj.Open(query,connObj);
Response.Write(
“Return Value= “

+RetVal);

/******Stored Procedure********/

Create Procedure ProcSP@StrName
nvarchar(10),@RetVal integer OUTPUT
AS
SET RetVal = 1

return
GOreturn
GO

 

Advertisements

February 8, 2009 - Posted by | Developement | ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: