Read and write to an access database using Javascript
First, make sure that '/\' and '\' (in connection string) is just a typo in SO.
Second, here is a version of Delete command:
function DeleteRecord() {var adoConn = new ActiveXObject("ADODB.Connection");var adoCmd = new ActiveXObject("ADODB.Command");adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\dbName.mdb'");adoCmd.ActiveConnection = adoConn;adoCmd.CommandText = "Delete * From tblName Where FieldName = 'Quentin'";adoCmd.Execute();adoConn.Close();}
And, Edit command (without looping -> updates all [matching] records):
function EditRecord() {var adoConn = new ActiveXObject("ADODB.Connection");var adoCmd = new ActiveXObject("ADODB.Command");adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\dbName.mdb'");adoCmd.ActiveConnection = adoConn;adoCmd.CommandText = "Update tblName Set FieldName = 'New Value' Where FieldName = 'Quentin'";adoCmd.Execute();adoConn.Close();}
Please note, I have not tested this (do not have Access right now), so there might be some syntax bugs...
Hope it works and helps.
function loadDB() { var connection = new ActiveXObject("ADODB.Connection"); var connectionstring = "Data Source=.;Initial Catalog=EmpDetail;Persist Security Info=True;User ID=sa;Password=Micr0s0ft;Provider=SQLOLEDB"; connection.Open(connectionstring); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open("select * from emp", connection); rs.MoveFirst(); var span = document.createElement("span"); span.style.color = "Blue"; span.innerText = " ID " + " Name " + " Salary"; document.body.appendChild(span); while (!rs.eof){ var span = document.createElement("span"); span.style.color = "green"; span.innerText = "\n " + rs.fields(0) + " | " + rs.fields(1) + " | " + rs.fields(2); document.body.appendChild(span); rs.MoveNext(); } rs.close(); connection.close();}