By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,714 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,714 IT Pros & Developers. It's quick & easy.

clientside access database with javascript

P: 2
Can anyone help me on this? I just need more information on all aspects of it. For example : how to add, delete, edit fields. Can i add new tables etc..

i know it is MS version of javascript so it only works in IE but thats perfect for my project and so is the clientside aspect of it as well, i know is easily hacked but I'm not worried about that since it is going to be used in an intranet setting.

here is a sample of what i am talking about everything works except the edit and i know its bulky but its just so i can see how its going to work then i will really get started on it, PLEASE help

[HTML]<html>
<head>

<script type="text/javascript">
<!--
var adOpenDynamic = 2;
var adLockOptimistic = 3;

/* Path of database.
*/
var strDbPath = "C:\\Sample.mdb";

/*
Here is the ConnectionString for Microsoft Access.
If you want to use SQL or other databases, you hav to change the connection string..
eg: SQL => var conn_str = "Provider=sqloledb; Data Source=itdev; Initial Catalog=pubs; User ID=sa;Password=yourpassword";
*/
var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbPath;

function EditRecord() {
var adoConn = new ActiveXObject("ADODB.Connection");
var adoRS = new ActiveXObject("ADODB.Recordset");

adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source='\\Sample.mdb'");
adoRS.Open("Select * From SampleTable Where Group = 'Quentin'", adoConn, 1, 3);

adoRS.Edit;
adoRS.Fields("Group").value = "New Name";
adoRS.Update;

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


function AddRecord() {
var adoConn = new ActiveXObject("ADODB.Connection");
var adoRS = new ActiveXObject("ADODB.Recordset");

adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source='/\Sample.mdb'");
adoRS.Open("Select * From SampleTable", adoConn, 1, 3);

adoRS.AddNew;
adoRS.Fields("Group").value = "Quentin";
adoRS.Update;

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

function getAdoDb(strAdoType){
if (window.ActiveXObject){
return new ActiveXObject(strAdoType);
}
else{
return ActiveXObject(strAdoType);
}
}

function showReports(){
try{
var strHtml ="";
strHtml += "<table cellpadding=0 cellspacing=0 border=1 width= '100%' align=center>";
strHtml += "<tr ><td align=center colspan=4><b>Sample Database Records</b></td></tr>";

//Database Connection
var conn = getAdoDb("ADODB.Connection");
conn.open(conn_str, "", "");

//Recordset
var rs = new ActiveXObject("ADODB.Recordset");
//strQuery = "SELECT * FROM SampleTable";
strQuery = "SELECT SampleTable.Date, SampleTable.Name, SampleTable.Group, SampleTable.Details FROM SampleTable";
rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);

if(!rs.bof){
rs.MoveFirst();
while(!rs.eof) {
strHtml += "<tr>";
strHtml += " <td><Font face ='tahoma'>" + rs.fields(0).value + "</font></td>";
strHtml += " <td><Font face ='tahoma'>" + rs.fields(1).value + "</font></td>";
strHtml += " <td><Font face ='tahoma'>" + rs.fields(2).value + "</font></td>";
strHtml += " <td><Font face ='tahoma'>" + rs.fields(3).value + "</font></td>";
strHtml += "</tr>";

rs.MoveNext();
}
}
else{
//No Records.
strHtml += "<tr colspan=4><td align=center><font color=red>No Records.</font></td></tr>";
}
conn.close();
strHtml += "</table>";
document.write(strHtml);
}catch(ex){
alert(ex.message);
}
}

//-->
</script>
<title>Call Log Details</title>
</head>

<!--<body onload="show_menu()">
<div id="main" />-->
<body>
<script language="JavaScript">
showReports();
</script>
<input name="Button" type="button" value="add" onClick="AddRecord()";><br>
<input name="Button" type="button" value="delete" onClick="EditRecord()";>
</body>
</html>
[/HTML]

thanks

chad
Oct 20 '07 #1
Share this Question
Share on Google+
6 Replies


missinglinq
Expert 2.5K+
P: 3,532
Since this is a javascripts issue, I'm going to move it to the javascript/ajax forum!

Welcome to TheScripts!

Linq ;0)>
Oct 21 '07 #2

acoder
Expert Mod 15k+
P: 16,027
Why not use an UPDATE query and make the edit via SQL?
Oct 21 '07 #3

P: 2
Why not use an UPDATE query and make the edit via SQL?



My only resources are javascript and ms access all clientside.
Oct 21 '07 #4

acoder
Expert Mod 15k+
P: 16,027
My only resources are javascript and ms access all clientside.
I meant instead of a SELECT query, use an UPDATE query, e.g.
Expand|Select|Wrap|Line Numbers
  1. UPDATE SampleTable set Group = "New Name" where Group = "Quentin"
Oct 22 '07 #5

P: 1
Hi. I'm interested in learning more about this technique but I don't know where to start.

I'm trying to prototype something like an asp.net gridview/details view kind of thing that has to use client side code and an access mdb (because it's completely offline - no IIS, .net etc).

Does anyone have any urls? I'm lost in google land..... Thanks
Dec 12 '07 #6

acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!
Hi. I'm interested in learning more about this technique but I don't know where to start.

I'm trying to prototype something like an asp.net gridview/details view kind of thing that has to use client side code and an access mdb (because it's completely offline - no IIS, .net etc).

Does anyone have any urls? I'm lost in google land..... Thanks
What code do you have so far?
Dec 12 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.