473,434 Members | 1,435 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,434 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 12559
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.