Link to home
Start Free TrialLog in
Avatar of maximyshka
maximyshka

asked on

Database connection with javaScript

How to connect to database with java script
Avatar of reginab
reginab

here are a couple of examples for you.

var DBConn = Server.CreateObject ('ADODB.Connection');
DBConn.Provider = "Microsoft.Jet.OLEDB.4.0"
DBConn.Open(Server.MapPath("PASS.mdb"))
if (DBConn.Errors.Count > 0)
         Response.Write("Error")

example:
=========================
<script>
     var conn = new ActiveXObject("ADODB.Connection") ;
     var connectionstring = "Provider=sqloledb; Data Source=itdev; Initial Catalog=pubs; User ID=sa;Password=yourpassword"
     conn.Open(connectionstring)
     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
     while(!rs.eof)
     {
              alert(rs(0));
              rs.movenext
    }
         
        rs.close
    conn.close      
</script>
Avatar of maximyshka

ASKER

is it javascript. It looks like vb?
ASKER CERTIFIED SOLUTION
Avatar of reginab
reginab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is there anyway to connect to database through odbc?