How To Accesss Ms Sql Databse Usin Activexobject

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashvinguna
    New Member
    • Nov 2007
    • 1

    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.


    [CODE=javascript]<SCRIPT type="text/javascript">
    <!--
    function Aufruf(){
    var rst;
    var dsn;
    var sql;
    var newWindow;
    try
    {
    var rst = new ActiveXObject(" ADODB.Recordset ");
    var connection = new ActiveXObject(" ADODB.Connectio n");
    connection.Open ("Provider=SQLO LEDB.1;Persist Security Info=False;User ID=myID;Initial Catalog=Projekt ;Data Source=MyServer ;pwd=mypass");
    sql = ("select moiveId, title from movie");
    rst.Open (sql, dsn);
    newWindow = window.open("", "","width=6 00, height=400,top= 200
    left=200,scroll bars");
    while (!rst.EOF){
    newWindow.docum ent.write(rst(0 ) + " " + rst (1));
    newWindow.docum ent.write("<br> ");
    rst.moveNext();

    rst.Close();
    }
    catch{
    txt="There was an error on this page.\n\n"
    txt+="Error description: " + err.description + "\n\n"
    txt+="Click OK to continue.\n\n"
    alert(txt)
    }[/CODE]
    Last edited by acoder; Nov 27 '07, 09:36 AM. Reason: Added code tags
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    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

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by ashvinguna
      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!

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by mzmishra
        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.

        Comment

        Working...