Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. connect to database using javascript

connect to database using javascript

Scheduled Pinned Locked Moved C#
helpjavascriptdatabasesysadminquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SatyaKeerthi15
    wrote on last edited by
    #1

    I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox

    OriginalGriffO N J R 4 Replies Last reply
    0
    • S SatyaKeerthi15

      I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Try posting this in the Javascript forum?

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • S SatyaKeerthi15

        I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        As mentioned you should have posted this to the JavaScript forum. ActiveXObject is an IE object and not officially supported in FireFox, AFAIK. Most importantly though you are exposing the details of your database, username, password, table, table structure; a huge breach of security.


        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        • S SatyaKeerthi15

          I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          Oh jeez, not only a conn string in javascript, but a conn string with an sa password! Looks like im going to be employed for the foreseeable future.

          1 Reply Last reply
          0
          • S SatyaKeerthi15

            I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox

            R Offline
            R Offline
            Ravi Sant
            wrote on last edited by
            #5

            If you had done little search on internet, you would have found the answer. Here is your solution.

            ♫ 99 little bugs in the code, 99 bugs in the code We fix a bug, compile it again 101 little bugs in the code ♫

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups