469,276 Members | 1,600 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,276 developers. It's quick & easy.

How To Accesss Ms Sql Databse Usin Activexobject

HI,
I AM TRYING TO ACCESS MS SQL 2005 DATABASE THROUGH JAVASCRIPT BUT IT GIVING ME RUNTIME ERROR.


Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type="text/javascript">
  2. <!--
  3. function Aufruf(){
  4. var rst;
  5. var dsn;
  6. var sql;
  7. var newWindow;
  8. try
  9. {
  10. var rst = new ActiveXObject("ADODB.Recordset");
  11. var connection = new ActiveXObject("ADODB.Connection");
  12. connection.Open ("Provider=SQLOLEDB.1;Persist Security Info=False;UserID=myID;Initial Catalog=Projekt;Data Source=MyServer;pwd=mypass");
  13. sql = ("select moiveId, title from movie");
  14. rst.Open (sql, dsn);
  15. newWindow = window.open("","","width=600, height=400,top=200
  16. left=200,scrollbars");
  17. while (!rst.EOF){
  18. newWindow.document.write(rst(0) + " " + rst (1));
  19. newWindow.document.write("<br>");
  20. rst.moveNext();
  21.  
  22. rst.Close();
  23. }
  24. catch{
  25.   txt="There was an error on this page.\n\n"
  26.   txt+="Error description: " + err.description + "\n\n"
  27.   txt+="Click OK to continue.\n\n"
  28.   alert(txt)
  29.   }
Nov 27 '07 #1
3 3651
mzmishra
390 Expert 256MB
As far I know JavaScript basically being a client side language cannot access a database which is usually in a server. A server side lang such as CGI, PHP, JSP, ASP or similar need to be used. Or you can use AJAX
Nov 27 '07 #2
acoder
16,027 Expert Mod 8TB
HI,
I AM TRYING TO ACCESS MS SQL 2005 DATABASE THROUGH JAVASCRIPT BUT IT GIVING ME RUNTIME ERROR.
What kind of runtime error?

PS. please don't use only caps when typing - it looks like you're shouting!
Nov 27 '07 #3
acoder
16,027 Expert Mod 8TB
As far I know JavaScript basically being a client side language cannot access a database which is usually in a server. A server side lang such as CGI, PHP, JSP, ASP or similar need to be used. Or you can use AJAX
JavaScript can't access a database, but ActiveX can. However, it's only supported by IE.
Nov 27 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Peter Kirk | last post: by
43 posts views Thread by shaanxxx | last post: by
3 posts views Thread by Sunny | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.