Database connection with javaScript

Posted on 2004-11-10
Last Modified: 2010-04-17
How to connect to database with java script
Question by:maximyshka
    LVL 4

    Expert Comment

    here are a couple of examples for you.

    var DBConn = Server.CreateObject ('ADODB.Connection');
    DBConn.Provider = "Microsoft.Jet.OLEDB.4.0"
    if (DBConn.Errors.Count > 0)

         var conn = new ActiveXObject("ADODB.Connection") ;
         var connectionstring = "Provider=sqloledb; Data Source=itdev; Initial Catalog=pubs; User ID=sa;Password=yourpassword"
         var rs = new ActiveXObject("ADODB.Recordset")
         rs.Open("SELECT gif, description, page, location FROM menu1", conn)
         // Be aware that I am selecting from this table, but you need to pick your own table

    Author Comment

    is it javascript. It looks like vb?
    LVL 4

    Accepted Solution

    here maybe this is more clear

    <script language=vbscript>
    sub fnTest()

         set con = createobject("ADODB.connection") "Provider=msdaora;user id=user;password=user;Data Source=Test"
         set rs =  createobject("ADODB.recordset")
         rs.Open "select sysdate from dual",con
         msgbox rs.Fields(0)
    end sub
    <input type=button value="Test" onclick="fnTest()">


    Author Comment

    is there anyway to connect to database through odbc?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Order table with macro 3 65
    wordsWithout 49 64
    pairs challenge 5 29
    How does Google get such fast response times? 5 67
    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now