View Full Version : Connect to an ACCESS DB housed on the client side
Basscyst
04-11-2004, 05:39 PM
Say I have an ACCESS DB and I want to Read \ Write to it without the use of a server. ie. Both the HTML page and the DB are both just on my machine. Is there a way to connect to the DB without the use of server-side scripting?
I tried Scroots' script in the Post a JavaScript forum but it doesn't seem to work when housed on my machine.
TIA,
Basscyst
Basscyst
04-11-2004, 06:21 PM
OK , I got this to work except the fieldName is coming back undefined. Yet it's there. This is kinda new to me, so any help is appreciated.
Here is the code I have, Attached is a copy of the DB there is just some fake info in it. Some tables are blank still.
<script type="text\javascript">
function query(){ //the function that connects and queries the database.
//open the DB
dbc = new ActiveXObject("ADODB.Connection");
dbc.Provider = "Microsoft.Jet.OLEDB.4.0";
dbc.ConnectionString = "Data Source=VerbalWarnings.mdb";
dbc.Open //open the database connection with the above settings
//create a recordset from an SQL query
rs = new ActiveXObject("ADODB.Recordset");
rs.ActiveConnection = dbc;
rs.CursorLocation = 3; //adUseClient
rs.LockType = 3; //adLockOptimistic
rs.Open ("Select * FROM Reps"); //open the sql query
alert(rs.RepID);
dba.close
}
document.onload=query()
</script>
glenngv
04-12-2004, 05:35 AM
try:
alert(rs.Fields("RepID"));
Basscyst
04-12-2004, 04:02 PM
Thanks Glenngv,
That was the problem, figured it out late last night.
Basscyst
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.