473,327 Members | 1,952 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,327 software developers and data experts.

How to connect to local MS Access Database using JavaScript?

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.

I tried the following ways but it failed miserably.... It'll be wonderful if you can
sort it out.
Expand|Select|Wrap|Line Numbers
  1.     function UpdateDB()
  2.     {
  3.         var strConnect = "TestDSN";
  4.         oConn = Server.CreateObject("ADODB.Connection");
  5.         oConn.Open(strConnect);        
  6.         var strSQL = "SELECT Name FROM TelephoneIndex;";
  7.         var rsAd=oConn.Execute(strSQL);        
  8.         Response.Write("First row is, "+ rsAd.Fields("Name") );        oConn.Close();
  9.  
  10.     }
  11.  
  12.  
Also tried this...

Expand|Select|Wrap|Line Numbers
  1.    function UpdateDB1()
  2.    {
  3.             var cn = new ActiveXObject("ADODB.Connection");
  4.             var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\My Documents\TestDB.mdb;"
  5.             cn.Open(strConn);
  6.             var rs = new ActiveXObject("ADODB.Recordset");
  7.             var SQL = "select count(*) from TelephoneIndex";
  8.             rs.Open(SQL, cn);
  9.             alert(rs(0));
  10.             rs.Close();
  11.             cn.Close(); 
  12.  
  13.    }
------------------------------------------------------------------------------------------------------------------
Jul 23 '07 #1
2 12542
pbmods
5,821 Expert 4TB
Heya, Abhi~Menon. Welcome to TSDN!

What errors are you getting?

P.S., removed superfluous '?'s from your title to make people more likely to want to read it.
Jul 24 '07 #2
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.

I tried the following ways but it failed miserably.... It'll be wonderful if you can
sort it out.
Expand|Select|Wrap|Line Numbers
  1.     function UpdateDB()
  2.     {
  3.         var strConnect = "TestDSN";
  4.         oConn = Server.CreateObject("ADODB.Connection");
  5.         oConn.Open(strConnect);        
  6.         var strSQL = "SELECT Name FROM TelephoneIndex;";
  7.         var rsAd=oConn.Execute(strSQL);        
  8.         Response.Write("First row is, "+ rsAd.Fields("Name") );        oConn.Close();
  9.  
  10.     }
  11.  
  12.  
Also tried this...

Expand|Select|Wrap|Line Numbers
  1.    function UpdateDB1()
  2.    {
  3.             var cn = new ActiveXObject("ADODB.Connection");
  4.             var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\My Documents\TestDB.mdb;"
  5.             cn.Open(strConn);
  6.             var rs = new ActiveXObject("ADODB.Recordset");
  7.             var SQL = "select count(*) from TelephoneIndex";
  8.             rs.Open(SQL, cn);
  9.             alert(rs(0));
  10.             rs.Close();
  11.             cn.Close(); 
  12.  
  13.    }
------------------------------------------------------------------------------------------------------------------
the above code is almost working
hi i want to know how to insert text box values into the ms access using javascript
Aug 31 '07 #3

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

Similar topics

11
by: Marcus | last post by:
Hello! I'm trying to write a VB.NET program that connects to a AS/400 Server. I've tried almost everything, but it will not connect. I've tried to set up a DSN using the Client Access...
3
by: asemeiks | last post by:
I'm using Access 97, Jet 4.0. the data resides on a Win 2000 domain server. Using .Net 1.1 and IIS 5.0 on a local XPPro computer I am trying connect to a Jet database on the server. If the data...
5
by: news.telia.net | last post by:
Hi! I have a question. I have installed php and mysql on an apache-server on windows and I can't connect to the server. I tried to create a database (since I am trying to learn howto). My...
0
by: Larry Rebich | last post by:
I am trying to use the sample web template that is distributed with Visual Studio 2005 called 'Personal Web Site Starter Kit'. After running for awhile it fails with the following message: ...
3
by: MSK | last post by:
Hi, I am a newbie to .NET/Networking if I develop a project in 1. VB.NET + SQL server database 2. ASP.NET + SQL server database 3. .NET ( vb or asp) + Access database
3
by: LamSoft | last post by:
I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server... Some of the Code.. protected void LoginButton_Click(object sender, EventArgs e) { if...
2
by: swarajtnj | last post by:
Hi Friends, I am using MySql 5.0. With the Front end as ASP.NET 2.0. I am working a small concern. my company local server to connect the MySql is perfectly working. But when i Connect to the...
6
by: Al G | last post by:
Can someone tell me what I need to get connected to our AS400? I am trying to write an app in VS2005(Data source, Gridview) that requires data from files on our AS400. I've downloaded DB2, and...
15
Zwoker
by: Zwoker | last post by:
Hi all, I am accessing data from an Oracle database via a connect string. I got into the situation where I wanted to write my SQL select statement to do a join between a local table sitting in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.