473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Connect to MS Access database using javascript

Can any one help me how to connect MS Access from Javascript with example?
Is any component required or that is to be installed in client side?
I have read that some component needs to be installed.
Jun 1 '07 #1
11 31149
r035198x
13,262 8TB
can any one help me how to connect msaccess from javascript with example?
is any component required or that is to be installed in client side?
in same forum i have seen that some component needs to be installed. so how to get that plz..give me
Java != Javascript.
Moved to Javascript forum.

To connect to a database, you need a server side script. Javascript is client side.
Jun 1 '07 #2
dmjpro
2,476 2GB
do u know a new technology ..... AJAX.
try to know it ... this ll help u to do this.
best of luck.

kind regards.
dmjpro.
Jun 1 '07 #3
acoder
16,027 Expert Mod 8TB
Changed thread title.
Jun 1 '07 #4
acoder
16,027 Expert Mod 8TB
Javascript cannot connect to a database, but you can make a request to a server-side page which does so using javascript (known as AJAX). Read up on Ajax in the Offsite Links thread at the top of this forum.
Jun 1 '07 #5
I think I've seen this done before somewhere, but of course I can't remember where exactly.

It is possible to connect to a client side database (Access) via Javascript.
Below is a sample connecting to a database on C.

It is running a query on a table called SampleTable, and returning a recordset of 4 fields.
The sysntax may be a little odd, it very like classic ASP in how it pages through the recordset.

Hope this helps

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.   <head>
  3.  
  4.   <script type="text/javascript">
  5.   <!--
  6.   var adOpenDynamic = 2;
  7.   var adLockOptimistic = 3;
  8.  
  9.   /* Path of database.
  10.   */
  11.   var strDbPath = "C:\\FolderName\\Sample.mdb";
  12.  
  13.   /*
  14.     Here is the ConnectionString for Microsoft Access.
  15.     If you want to use SQL or other databases, you hav to change the connection string..
  16.     eg: SQL => var conn_str = "Provider=sqloledb; Data Source=itdev; Initial Catalog=pubs; User ID=sa;Password=yourpassword";
  17.   */
  18.   var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbPath;
  19.  
  20.   function getAdoDb(strAdoType){
  21.     if (window.ActiveXObject){
  22.         return new ActiveXObject(strAdoType);
  23.     }
  24.     else{
  25.         return ActiveXObject(strAdoType);
  26.     }
  27.   }
  28.  
  29.   function showReports(){
  30.     try{
  31.         var strHtml ="";
  32.         strHtml += "<table cellpadding=0 cellspacing=0 border=1 width= '100%' align=center>";
  33.         strHtml += "<tr ><td align=center colspan=4><b>Sample Database Records</b></td></tr>";
  34.  
  35.             //Database Connection
  36.        var conn = getAdoDb("ADODB.Connection");
  37.        conn.open(conn_str, "",   "");
  38.  
  39.        //Recordset
  40.        var rs = new ActiveXObject("ADODB.Recordset");
  41.        //strQuery = "SELECT * FROM SampleTable";
  42.        strQuery = "SELECT SampleTable.Date, SampleTable.Name, SampleTable.Group, SampleTable.Details FROM SampleTable";
  43.        rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);
  44.  
  45.        if(!rs.bof){
  46.           rs.MoveFirst();
  47.           while(!rs.eof) {
  48.              strHtml += "<tr>";
  49.              strHtml += " <td><Font face ='tahoma'>" + rs.fields(0).value + "</font></td>";
  50.              strHtml += " <td><Font face ='tahoma'>" + rs.fields(1).value + "</font></td>";
  51.              strHtml += " <td><Font face ='tahoma'>" + rs.fields(2).value + "</font></td>";
  52.              strHtml += " <td><Font face ='tahoma'>" + rs.fields(3).value + "</font></td>";
  53.              strHtml += "</tr>";
  54.  
  55.              rs.MoveNext();
  56.           }
  57.        }
  58.        else{
  59.          //No Records.
  60.          strHtml += "<tr colspan=4><td align=center><font color=red>No Records.</font></td></tr>";
  61.        }
  62.        conn.close();
  63.            strHtml += "</table>";
  64.            document.write(strHtml);
  65.     }catch(ex){
  66.       alert(ex.message);
  67.     }
  68.   }
  69.  
  70.   //-->
  71.   </script>
  72.   <title>Call Log Details</title>
  73.   </head>
  74.  
  75.   <!--<body onload="show_menu()">
  76.     <div id="main" />-->
  77.   <body>
  78.     <script language="JavaScript">
  79.       showReports();
  80.     </script>
  81.   </body>
  82.   </html>
  83.  
Jun 15 '07 #6
acoder
16,027 Expert Mod 8TB
It is possible to connect to a client side database (Access) via Javascript.
That is not Javascript, it is JScript (Microsoft's version). It would only work in IE with security restrictions relaxed.
Jun 15 '07 #7
Sunlis
2
I realize that this thread has been quiet for a while now, but this is the closest thing I can find to a solution to my problem.

In a project of mine, users need to be able to register, and I need it to be done using client-side script, I need it to write to a MS Access database.
There are 6 fields, firstname, lastname, email, countryorregion,stateorprovince, and password.
They also need to be able to log-in, using their first & last names, and a password, all of which they provide upon registration.

I've been trying to get this to work for days now, but I know almost no javascript or php.
Any help would be GREATLY appreciated.

-Sunlis
Jun 22 '07 #8
acoder
16,027 Expert Mod 8TB
Login should always be done server-side. In any case, you can't connect to a database using Javascript, but you can make a http request to a server-side script (e.g. in PHP) which will make the necessary database transactions. This would be done using something called Ajax.
Jun 23 '07 #9
@acoder
Not exactly, this is server-side code. You can also accomplish this as you would in VBscript
Mar 3 '10 #10
@acoder
Not quite accurate, this is server-side code, so it's not intended to be intepreted by the browser. So it will work regardless of the client's browser.
Mar 3 '10 #11
acoder
16,027 Expert Mod 8TB
Heh, try that on a non-IE browser. It looks like ASP, but it isn't. This is client-side code connecting to an Access database on the client.
Mar 15 '10 #12

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

Similar topics

0
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t...
17
by: kartheek | last post by:
hi friends, can any one out here help me by giving me the code to connect to an MSACCESS database using javascript.
7
by: mahipalerasani | last post by:
I am trying to connect to the Access database for querying, inserting and updating the data using 'C' API's. If somebody has code to connect to Access Database using C API's can you you please...
1
by: Sunlis | last post by:
I need to find a way to communicate with a MS Access database using Javascript, PHP, or some other client-side scripting. It's for a Computer Science exam, and I cannot solve this problem. Users...
2
by: Abhi~Menon | last post by:
I've a situation here where i want to interact with the local Access Database from an HTML page. I've created a DSN for the Access. I'm wondering how the connection part has to made from Java Script....
0
by: asad56 | last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is...
5
by: lintolawrance | last post by:
hi friends, can any one out here help me by giving me the code to connect to an SOL database using javascript.
3
by: mkhizess | last post by:
Hi Buddzy Can you plz help to connect to Access DataBase input from HTML form using insert statement. I am still new on programming with html here is my code . <html> <head> ...
6
9815402440
by: 9815402440 | last post by:
hi i have a ms access database which is on web server (ftp://www.abc.com) . i want to connect this database using ado in vb6. please help regards manpreet singh dhillon hoshiarpur
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.