I have to display marks of my students through my site. The database is created using Microsoft Access. How can I display the marks of each student in a table, as they enter the registration number?
-
Possible duplicate of: Are there JavaScript bindings for MySQL?.Peter Mortensen– Peter Mortensen2011-04-12 14:36:14 +00:00Commented Apr 12, 2011 at 14:36
-
the link from @PeterMortensen is incorrect and should be stackoverflow.com/questions/298057/…kttii– kttii2019-12-13 15:07:30 +00:00Commented Dec 13, 2019 at 15:07
10 Answers
JavaScript can't directly access the database. You'll need to have some server-side component that takes requests (probably via HTTP), parses them and returns the requested data.
Then the JavaScript could access that component to fetch the data (hm ... smells like AJAX).
2 Comments
I know this is an old question, but I happened to come across this project, AccessDB, at the same time as this question so I figured I'd post it. Note that it says it is for use with Internet Explorer. I'm guessing they are using a Microsoft only feature to access the file, but I really haven't looked into it.
From their website:
ACCESSdb is a JavaScript library used to dynamically connect to and query locally available Microsoft Access database files within Internet Explorer. All you need is an .mdb file; Access does not even need to be installed!
Comments
Why do you want to use Javascript? It runs in the browser of the site's visitors, and even if there were a way to have it directly access a database (which there isn't), it would be a horrible security risk, since it would have to contain the DB password, so that each visitor of the site could get full access to the DB.
What you need is something that runs on the server and accesses the DB to deliver different pages to the visitor depending on data entered in an HTML form. Typical languages used for this are PHP, Perl, Ruby or ASP.
Also note that MS Access is a very poor choice as a DB backend to a web app since it does not support concurrent access from different users.
All in all it looks like you need more direct help than this site can provide; try finding a web app specialist in your area.
7 Comments
This question has been asked a long time ago, recently i found something helpful for future visitors. You can actually access your database via this javaScript library called mysqljs,which can be downloaded from http://www.mysqljs.com
Code synax:
MySql.Execute(
"mysql.yourhost.com",
"username",
"password",
"database",
"select * from Users",
function (data) {
console.log(data)
});
Note: There is no security by default in this you are to code your own security
Comments
If you're looking for client-side database access, then what everyone else said.
If you're just looking for a way to access a database (NOT in a browser), and Javascript is the language you're most comfortable with, try JSDB. (It's a Javascript shell that has bindings for databases via ODBC, SQLite, and flat files) I've used it a lot and it's my preferred scripting shell.
Comments
JavaScript (or any client-side language) has no ability to access something which is still located on the server. You're best option is to use an AJAX implementation and have a series of web services which you can query from your JavaScript and return the results in a usable format (most likely JSON).
Comments
You are think from a client side, whereas you should be thinking on the server side.
You need a script on the server side that will query Access, and create the HTML for it, depending upon the value of a registration number supplied in a form.
The scripting language is up to you. Given that you are using Access, I imagine one of the Microsoft family of languages would be best, and that your institution will have a web server already (presumably IIS) to host your website.
First things first:
- What server software is your institution running? This determines the best programming language to use.
- What budget do you have. If it is near zero, then you are looking at free IDEs. It might be better to develop in Eclipse and deploy on Tomcat, regardless of the server OS.
- What languages do you know?
- Get a book on programming websites using your technology of choice. For example with Java I'd suggest using Struts and Tiles for a simple website like this.
- You might want to migrate the data from Access to a database backend - MSSQL if your institution already has a license, or MySQL or PostgreSQL if you have a budget of zero.
From your question it sounds like this is all new to you. This is a small project however, so an ideal start to learning how to write interactive websites.
Comments
Here is a simple ASP (vbscript) script that will dump your data into a table. You can edit the path and query to suit your situation. As mentioned by others, it does not provide decent security.
Call it with FILENAME.asp?regno=xxxxx
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:/YourDatabase.mdb"
SQL = "Select * from TABLENAME where regno=" & request("regno")
set RS= Conn.execute(SQL)
%>
<table>
<tr>
<% for x=0 to rs.fields.count-1 %>
<th><%=RS.fields(x).value%></th>
<% next %>
</tr>
<% do until RS.eof %>
<tr>
<% for x=0 to rs.fields.count-1 %>
<td><%=RS.fields(x).value%></td>
<% next %>
</tr>
<% rs.movenext %>
<% loop %>
</table>
<%
RS.close()
set Conn=nothing
%>