How can I link to an Access database using JavaScript?

advertisements
            <div class="main-container">

                    Username:<br>
                    <input type="text" name="uname" value="Username">
                    <br>
                    Password:<br>
                    <input type="password" name="pword" value="Password">
                    <br><br>
                    <input type="submit" value="AddRecord">
                    <input type="reset" value="Cancel">
            </div>
        </div>
</body>

<script type="text/javascript">
function AddRecord() {
var adoConn = new ActiveXObject("ADODB.Connection");
var adoRS = new ActiveXObject("ADODB.Recordset");

adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\\Documents\\Writings.mdb");

adoRS.Open("Select * From User", adoConn, 1, 3);
        if(!rs.bof){
        rs.MoveFirst();
            while(!rs.eof){
                var data=rs(1);
                if(data==user.value){
                alert("This user already exists!");
                exists=1;
                }else{
                break;
                rs.movenext();
                }
            }
        }

if(exists!=1){

adoRS.AddNew;
adoRS.Fields("UserName")=user.value;
adoRS.Update;

adoRS.Close();
adoConn.Close();  

alert("User successfully registered!");
document.cookie=user.value;

window.location="https://www.google.co.uk";
}
</script>

This doesn't work the button does nothing. I've tried moving my database but that also doesn't work. I currently work using Google Chrome. My database is called Writings and is the folder documents. The website is supposed to get the information inputted from the text boxes and put it in the table but fro some reason it doesn't work


When you are creating a webpage, you usually want people to browse it and then fill and submit. In the code you showed, the database is local so if 100 people want to submit, each has the own database or all need to use same computer. For this kind of job you need to use a web service that is working with a central database and then, you can use javascript to call that service to insert data into database. For example you can use c# with MS Sql server or even Access database or use php with mysql.