Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

dataconnection in javascript

Posted on 1999-07-13
3
Medium Priority
?
335 Views
Last Modified: 2008-03-17
asp sorce code (server side)

how to connect data source name(dsn)connection using javascript

for example <%@language="vbscript"%>
like this we have to use javascript instead of vbscript

please answer with code example
0
Comment
Question by:shakila
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:PBall
ID: 1289240
var conn = Server.CreateObject("ADODB.Connection");
conn.open "DSN here","username here","password here"
:
: do whatever here
:
conn.close
conn = null

to specify code to run on server, you can change that directive to @language="JScript"

or put the code in a script block

<SCRIPT LANGUAGE="JavaScript" RUNAT=SERVER>
:
:code here
:
</SCRIPT>
0
 

Accepted Solution

by:
sadhu earned 120 total points
ID: 1289241
Hi shakila

Here is some code that populates a list box with database info. Just change the DSN and SQL statement and it is ready to go.


<html><head>
<title>jdblist.asp</title>&
<body>
<%@language="JScript"%>
<%
   var my_SQL = "select distinct state from publishers"
   var my_DSN = "DSN=student;uid=student;pwd=magic"

   var objconn = new ActiveXObject("ADODB.Connection");
 
   objconn.open(my_DSN);
   var rstemp=objconn.execute(my_SQL);
   if (rstemp.eof==true)
      {
      Response.Write ("no data for<br>");
      Response.Write (my_SQL);
      rstemp.Close
      rstemp=Nothing
      objconn.close;
      objconn=Nothing;
      Response.End
      }
%>
<Form><Select>
<%
while (rstemp.eof==false)
      {
%>
      <option> <%=rstemp(0).value%> </option>
      <%
      rstemp.movenext();
      }
loop

rstemp.close;
rstemp=null;



objconn.close;
objconn=null;
%>

</body>
</html>

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6872998
GREETINGS!

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question