getting values from a database using JS

B

Bali

Hi Guys,

I am trying to get values from a SQL Server database from within JS
code and I don't want to implement web-services. Could someone please
put up some sample code.

I have made a data connection called GetEmployeesData that retrieves
data from the pubs database. What I need to do is be able to change the
SQL Query from within JS code so that I select only rows based on some
value selected by the user and then get the result from the
database(which would only be one row). Can anybody please show me in js
code how this could be done.

Thanks

Sumeet
 
F

Franck Dauché

Hi,

For direct connection to a DB using sripting, have you tried something like:

var data
var strConn = your connection string to your SQL DB;
var objRs = new ActiveXObject("ADODB.Recordset");
var strCommm = "SELECT X FROM TABLE_NAME";
objRs.Open(strComm, strConn, adOpenForwardOnly, adLockReadOnly, adCmdText);
objRs.MoveFirst();
data = objRs(Your_Field_Name);
objRs.Close();

Hope that it puts you on the right track.

Franck Dauché
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top