IT Community - Software Programming, Web Development and Technical Support

Accessing SQL server Database using java script

This is a discussion on Accessing SQL server Database using java script within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Accessing SQL server Database using java script Connecting Database using javascript: Goal: This is a pure javascript project and it ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2007, 12:09 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Accessing SQL server Database using java script

Accessing SQL server Database using java script

Connecting Database using javascript:

Goal:

This is a pure javascript project and it is used to access tables.


Source:

<html>
<head>
<SCRIPT LANGUAGE=javascript>

function ConDB()
{
var conn = new ActiveXObject("ADODB.Connection") ;
alert(conn);

// replace <server ip>,<ur catalog>,<user> and <password> with apporpriate values

var connectionstring="Data Source=<server ip>";Initial Catalog=<ur catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";


alert(connectionstring);
conn.Open(connectionstring);
alert(conn);
var rs = new ActiveXObject("ADODB.Recordset");
alert(rs);
rs.Open("SELECT * FROM users ", conn);
rs.MoveFirst
while(!rs.eof)
{
document.write(rs.fields(1));
rs.movenext;
}

rs.close;
conn.close;
}
</SCRIPT>
</head>
<body OnLoad="javascript:ConDB()">
</body>
</html>

save this as a html page to run.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Client side JavaScript and and Server side Java Script sathian HTML, CSS and Javascript Coding Techniques 2 11-09-2007 10:30 PM
how to rectify java script runtime error vel.m8 HTML, CSS and Javascript Coding Techniques 1 11-04-2007 09:42 PM
Can an html and Java script be separated and the script placed in the cgi-bin? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 09-13-2007 06:11 AM
difference between Client side JavaScript and and Server side Java Script? Sundaram HTML, CSS and Javascript Coding Techniques 1 09-05-2007 11:46 AM
Accessing COM component using java script oxygen HTML, CSS and Javascript Coding Techniques 1 07-18-2007 02:25 AM


All times are GMT -7. The time now is 12:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0