PDA

View Full Version : add record to access db with javascript


Mojeaux65
05-21-2006, 02:25 PM
Hi Again...

I converted a small vbscript over to javascript to add/append a record to an access db. The script is running client side across a lan.

When I run the script it appears to run fine (I'm not getting errors), but when I check the db.. no record was added. What am I missing here?

<SCRIPT type=text/javascript>

function CheckPassword(){
var polnum;
var appnam;
var relshp;
var rst;
var conn;
var sql;

polnum = document.main.PWD1.value;
appnam = document.main.appnam.value;
relshp = document.main.relshp.value;

rst = new ActiveXObject("ADODB.Recordset");
conn = new ActiveXObject("ADODB.Connection");
conn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\server\\data\\TESTDB\\testdb.mdb;Persist Security Info=False");

sql = ("INSERT INTO REFERRALS (REFNO, APPNAME, UWRTR) VALUES (polnum, appnam, relshp)");

rst.Open (sql, conn);

alert("It worked");

conn.Close;
rst.Close;
}

</SCRIPT>

One other note... the script only adds 3 fields of a record that normally has about 25. Could this prevent the record from adding/appending?

As always, thank you for your time and help!!

Nook Schreier
05-21-2006, 07:03 PM
\\\\server\\data\\TESTDB\\testdb.mdb

Does "everyone" have full access (Read & Write) to the file and folder?

Also, my knowledge of JavaScript <-> SQL is limited. Do you need the parentheses around this statement:

sql = ("INSERT INTO REFERRALS (REFNO, APPNAME, UWRTR) VALUES (polnum, appnam, relshp)");

Mojeaux65
05-22-2006, 12:09 PM
Yes to the () question and the variables should be " + polnum + ", etc.....

Thanks!