We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,620 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion   Closed to New Replies

how to connect ms access database to html webpage

i am developing a website in html in which the contactus page i have to connect to ms access database i am not able to get it ,can any one tell me how to get that one.

26
Contributors
20
Replies
4 Years
Discussion Span
1 Year Ago
Last Updated
39
Views
bapu435
Newbie Poster
9 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

You need to use a server side programming language like ASP to do this. HTML cannot access a database itself.

stymiee
He's No Good To Me Dead
Team Colleague
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
Skill Endorsements: 3

<html>
<head>
<title>Entitled Document</title>
<script language="JavaScript" >

function getSubmit()
{
var LastName;
var Firstn = names.value ;

var cn = new ActiveXObject("ADODB.Connection");
//here you must use forward slash to point strait
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/clientDB.mdb";
var rs = new ActiveXObject("ADODB.Recordset");
//var SQL = "INSERT INTO Customers(FirstName, Surname)"
//+ " VALUES ( '"+ names.value +"', '" + surname.value +"')";
var SQL = "select Surname, DOB from Customers where FirstName = '" + Firstn + "'";

cn.Open(strConn);
rs.Open(SQL, cn);
surname.value = rs(0);
DOB.value = rs(1);
//alert(rs(0));
rs.Close();
cn.Close();


}

</script>
</head>
<body>

<input type="text" name="names" />
<input type="text" name="surname" />
<input type="text" name="DOB" />
<input type="button" value="submit" onclick="getSubmit()">

</body>
</html>

mkhizess
Newbie Poster
2 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hello i cant get output for the above coding pls help.

hidash_in
Junior Poster in Training
86 posts since Oct 2007
Reputation Points: 1
Solved Threads: 0
Skill Endorsements: 0

hello i cant get output for the above coding pls help.

You have to save the file with .asp extension for the IIS server to interpret it correctly. Also it would be helpful if you post the output you are currently getting, as most probably you giving incorrect path for your access file.

Shobhit
Newbie Poster
7 posts since Sep 2005
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

[inline] as far as my knowledge goes u can't achieve this by javascript as well, try doin something like this [/inline]

<html>
<%@ page import="java.sql.*"%>
<%
var LastName; 
var Firstn = names.value ; 
var cn = new ActiveXObject("ADODB.Connection"); 
//here you must use forward slash to point strait 
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/clientDB.mdb"; 
var rs = new ActiveXObject("ADODB.Recordset"); 
//var SQL = "INSERT INTO Customers(FirstName, Surname)" 
//+ " VALUES ( '"+ names.value +"', '" + surname.value +"')"; 
var SQL = "select Surname, DOB from Customers where FirstName = '" + Firstn + "'"; 
cn.Open(strConn); 
rs.Open(SQL, cn); 
surname.value = rs(0); 
DOB.value = rs(1); 
//alert(rs(0)); 
rs.Close(); 
cn.Close();
}
catch(Exception e)
{
out.println("error occured:" + e.getMessage());
}
%>
</body>
</html>

[inline] save this as .jsp and add some code for displayin gthe fields. hope this will help u [/inline]

techna
Newbie Poster
10 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi,
any one can help me out i have a excel database and want to show records in a html application; like i have employee code and their quality scores how i can show it in html form by putting emp code.

kapil.soni
Newbie Poster
1 post since May 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Use the "Save as web page" option in the File menu.

Notice that html can't access a spreadsheet on your computer. You have to upload the changed web page after any changes to the spreadsheet.

MidiMagic
Nearly a Senior Poster
3,363 posts since Jan 2007
Reputation Points: 730
Solved Threads: 184
Skill Endorsements: 1

You are able to connect to Microsoft Access using JavaScript when the HTML file is run locally and the Access .mdb file is accessible to the file system it does not work remotely due to the obvious security issues.

I had a situation where this functionality was actually useful, so I wrote a JavaScript library to simplify the process. This library allows you to execute SQL queries in a single command with the option of selecting the output format of the result-set from choices including JSON, XML, and HTML.

I had a great deal of difficulty finding information or examples of how to connect to Access, so I decided to share my code with the world...

The library is called ACCESSdb and you can get it here!

:thumbs:

faulkj
Newbie Poster
3 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi,

I am creating something similar as discussed above.

I have a access database which has the list of banking centers and their hours of operation ,Monday -Sunday.

Now, i have created a html page, asking the user to select the state from a drop down menu, and the day as checkbox. So that when I click on "Submit Query' button, it gives me all the banking centers of that state open on Monday and at which time.

I want to link this HTML.html file with my access table.
Also, i want to have a out put screen in html/access form which shows the result.

Appreciate, what all you can make available.

Thanks

goaway
Newbie Poster
2 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

plz if u get solution plz forward me too becoz i m also have same prob

navinsharma
Newbie Poster
2 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

plz if u get solution plz forward me too becoz i m also have same prob
at <snip>

navinsharma
Newbie Poster
2 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

If you are targeting Explorer only
you can always use a super lightwieght DSO to access data
go to MSDN and search for "Data Source Object" you'll find all that you need.

Troy III
Master Poster
779 posts since Jun 2008
Reputation Points: 140
Solved Threads: 100
Skill Endorsements: 5

plz if u get solution plz forward me too becoz i m also have same prob

hi...
now it will work
The given example program for retrieving the data from database

<html> 
<head> 
<title>Entitled Document</title> 
<script language="JavaScript" > 

function getSubmit() 
{ 

var Firstn = names.value ; 

var cn = new ActiveXObject("ADODB.Connection"); 

var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/clientDB.mdb"; 
var rs = new ActiveXObject("ADODB.Recordset"); 


var SQL = "select Surname, DOB from Customers where FirstName = '" + Firstn + "'"; 

cn.Open(strConn); 
rs.Open(SQL, cn); 
surname.value = rs(1); 
DOB.value = rs(2); 

rs.Close(); 
cn.Close(); 


} 

</script> 
</head> 
<body> 

<input type="text" name="names" /> 
<input type="text" name="surname" /> 
<input type="text" name="DOB" /> 
<input type="button" value="submit" onclick="getSubmit()"> 

</body> 
</html>
sanjeev.vermas
Newbie Poster
1 post since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Just use the "Save as web page" option in the File menu.

Thanks for the help.

But I had a query, where the database connection specified here, is FOR A sql SERVER .

var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/clientDB.mdb"; 
var rs = new ActiveXObject("ADODB.Recordset");

Now , do I have to configure my Access Database in someway?

Here is my HTML Code:

<head>
Select STATE: <SELECT NAME="entry4">
<OPTION VALUE="no1">STATE
</SELECT>
<form>
MONDAY
<input type="checkbox" />
<br />
TUESDAY
<input type="checkbox"/>
<br />
WEDNESDAY
<input type="checkbox"/>
<br />
THURSDAY
<input type="checkbox"/>
<br />
FRIDAY
<input type="checkbox"/>
<br />
SATURDAY
<input type="checkbox"/>
<br />
SUNDAY
<input type="checkbox"/>
</form> 
To submit the query, press: 
<INPUT TYPE="submit" VALUE="Submit Query">. <P>
</head>
<html>
  <head>
    <h1>Accessing Data through HTML and Access</h1>
  </head>
  <body>
    Looking at Excel Web Components to create a DAP
  </body>
</hmtl>

The idea is to select teh state and day

I have a ACCESS DB, which has all the details of a partuclar state and its working hours.

Need help in connecting both of them.

Thank You

goaway
Newbie Poster
2 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

i read above and do try it but some error
Line no. :20
char:1
Error: No value give for one or more required parameters.
code: 0
URL: file://c:\documents \...\...\...\.html

hitmale11
Newbie Poster
1 post since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi Guys,

Here is the same code in javascript and it works 100%. I'm so proud...:'(

<html> 
    <head> 
        <title>Entitled Document</title> 
        <script language="JavaScript"> 
        function getSubmit() 
	{ 
	var LastName; 
	var Firstn = names.value ; 

 
            	var cn = new ActiveXObject("ADODB.Connection"); 
            	var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = ClientDB.mdb;Persist Security Info=False"; 
            	cn.Open(strConn);
		var rs = new ActiveXObject("ADODB.Recordset"); 
		var SQL = "select Surname, DOB from Customers where FirstName = '" + Firstn + "'";

		rs.Open(SQL, cn); 
		surname.value = rs(0); 
		DOB.value = rs(1); 
            	rs.Close(); 
            	cn.Close();   
        } 
        </script> 
    </head> 
    <body> 

	name<input type="text" name="names" /> 
	Surname<input type="text" name="surname" /> 
	DOB<input type="text" name="DOB" /> 
	<input type="button" value="submit" onclick="getSubmit()"> 

	</body> 

</html>
HenniePj
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I am developing a website in html in which the contact us page i have to connect to MS-Excel database i am not able to get it ,can any one tell me how to get that one.

alphatechnology
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi,
I want to connect my html pages with access databese.
Can any of one help me?
Sonu Rohilla

Sonu Rohilla
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Please help me with code I will use to connect my xhtml web page with my access database.
You can replay by posting on this page or send me message through this e-mail [snipped]

Thank You

namadi
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page generated in 0.1326 seconds using 2.74MB