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. Web Development
  3. Javascript and database

Javascript and database

Scheduled Pinned Locked Moved Web Development
javascriptdatabasehelptutorialquestion
5 Posts 4 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.
  • R Offline
    R Offline
    ronapost
    wrote on last edited by
    #1

    Hello, does anyone know if it possible to read data from a javascript form and write it into a database (Access for example)? I have an online form that i used with cgi-mail and now i need to save the info on a database, any help would be appreciated... Thanks Rona

    B D T 3 Replies Last reply
    0
    • R ronapost

      Hello, does anyone know if it possible to read data from a javascript form and write it into a database (Access for example)? I have an online form that i used with cgi-mail and now i need to save the info on a database, any help would be appreciated... Thanks Rona

      B Offline
      B Offline
      Bradml
      wrote on last edited by
      #2

      JavaScript should never directly communicate with a database because then the user would be able to see the passwords etc for it. What you should do is have it call a PHP/ASP page that will do the database work for it.


      Brad Australian By contacting your lawyer you negate the right to sue me.

      1 Reply Last reply
      0
      • R ronapost

        Hello, does anyone know if it possible to read data from a javascript form and write it into a database (Access for example)? I have an online form that i used with cgi-mail and now i need to save the info on a database, any help would be appreciated... Thanks Rona

        D Offline
        D Offline
        Dominic Pettifer
        wrote on last edited by
        #3

        JavaScript is a scripting language that runs inside the browser and stays inside the browser. JavaScript can't be made to access anything external on the users computer, such as files on the users hard drive, or change settings on the users computer. If it did it would constitute a major security risk. So basically what you're asking is impossible, you can't access a database directly but, as the other poster says, you could do it indirectly via a server side script in ASP/PHP etc, but it would have to be a database on the server and not on the users computer. You could get JavaScript to initiate a page post back, or use Ajax to call a server side ASP.NET page which connects to the database.

        Dominic Pettifer Blog: www.dominicpettifer.co.uk

        1 Reply Last reply
        0
        • R ronapost

          Hello, does anyone know if it possible to read data from a javascript form and write it into a database (Access for example)? I have an online form that i used with cgi-mail and now i need to save the info on a database, any help would be appreciated... Thanks Rona

          T Offline
          T Offline
          Torsten Mauz
          wrote on last edited by
          #4

          Yes it is possible, but unless you really really really need to (and even if you think you need to you probably don't and you certainly shouldn't) then don't.

          var objConn = new ActiveXObject('ADODB.Connection');
          var objRs = new ActiveXObject('ADODB.Recordset');

          objConn.Open(conn_string);
          objRs.Open('SELECT * FROM table', objConn, 2, 3);

          if(!objRs.BOF)
          {
          objRs.MoveFirst();
          while(!objRs.EOF)
          {
          document.writeln(objRs.Fields("title").Value +'<br/>\n');
          objRs.MoveNext();
          }
          }

          It will work, but you will have to have extremely low security settings in IE (it will only work in IE). The user will also get a couple of security warnings which you can't get rid of. The above is provided merely as evidence that it is possible, if you haven't got the hint yet then I'll say once more.... please don't use this for anything other then learning. As you're using cgi-mail, you obviously have access to some server-side technology so use that for communicating with your DB. HTH

          D 1 Reply Last reply
          0
          • T Torsten Mauz

            Yes it is possible, but unless you really really really need to (and even if you think you need to you probably don't and you certainly shouldn't) then don't.

            var objConn = new ActiveXObject('ADODB.Connection');
            var objRs = new ActiveXObject('ADODB.Recordset');

            objConn.Open(conn_string);
            objRs.Open('SELECT * FROM table', objConn, 2, 3);

            if(!objRs.BOF)
            {
            objRs.MoveFirst();
            while(!objRs.EOF)
            {
            document.writeln(objRs.Fields("title").Value +'<br/>\n');
            objRs.MoveNext();
            }
            }

            It will work, but you will have to have extremely low security settings in IE (it will only work in IE). The user will also get a couple of security warnings which you can't get rid of. The above is provided merely as evidence that it is possible, if you haven't got the hint yet then I'll say once more.... please don't use this for anything other then learning. As you're using cgi-mail, you obviously have access to some server-side technology so use that for communicating with your DB. HTH

            D Offline
            D Offline
            Dominic Pettifer
            wrote on last edited by
            #5

            it will only work in IE

            So for all intents and purposes, it doesn't work ;)

            Dominic Pettifer Blog: www.dominicpettifer.co.uk

            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