Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a web frontend to an Access backend

Status
Not open for further replies.

t1hodges

MIS
May 8, 2003
54
I Need to create a web page that allows users to first log in, then second add, edit, and delete records in an access database. there will be aprox. five users.
 
I would ask in the forum for whatever server-side scripting you will be using (which pretty much depends on which web server you are using).

You would not use client-side JavaScript to do this.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
To clarify: You might have some client-side JavaScript on some of the pages (for simple client-side validation, etc)... but you would use server-side scripting to do the bulk of the work (accessing the DB, deleting, adding, logging in with sessions, etc).

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
ok...Is there anyone else out there who can answer my question?
 
You will need to use server side scripting such as ASP to read and write to and from the Access database.

This is the javascript forum, you wouldn't use javascript to talk to the database.

Using ASP and a correctly set up DSN you would do something like the following to get some data from the database:
(my ASP is rusty so forgive any errors - this is the general idea though)

Code:
 dim oRSstuff
dim strSQL

strSQL = "SELECT stuff, moreStuff, yetMoreStuff FROM aTable WHERE something=somethingElse"

set oRSstuff=Server.CreateObject("ADODB.recordset")
oRSstuff.open strSQL, "DSN=myDSN"


'do something here with the resulting recordset
Response.write "<p>" & oRSstuff['stuff'] & "</p>"
Response.write "<p>" & oRSstuff['moreStuff'] & "</p>"
Response.write "<p>" & oRSstuff['yetMoreStuff'] & "</p>"

'this last bit closes the connection and cleans up
oRSstuff.close
set oRSstuff=nothing

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
Also, perhaps actually asking a question will help. If your question is "How do I do it," then BillyRayPreachersSon has already answered it. Then Foamcow answered it. Maybe you have a different question, or a more detailed question?
 
Do any of you know server-side javascript? the problem is that our RAD group is not allow to use any of the obvious it solutions. Im very good with access, excel and vba. I want to use asp but we are not allowed
 
I dont know. thats way im here. I can develop data access pages but I want to build something robust. And If It cant be done, it cant be done. I live with it.
 
If you cannot use server-side scripting of any kind, and want this to be cross-browser, I'd give up now.

You might get lucky with an IE-only client-side solution, but I wouldn't know how to do this.

Personally, I'd advise that you go server-side (see my first post... oh wait - you already did). If you don't have the infrastructure in place to do this, then I suggest you work towards that.

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Yeah. I think im giving up. Sorry about my brashness but I didnt want everyone to go off on the asp tangent; I know that route.

Thanks for all your responses :)

Tack care.
 
Server-side Javascript IS ASP so if you do not have support for ASP you are not going to have it for Javascript (server-side) either.

But you may still have other server-side languages available such as PHP or CGI.

If you can restrict use to IE browsers only you can use .HTA files and then use Javascript or VBScript to do what you need. A .hta file will run with local PC privledges (that of the current logged on user) and therefore does not have the limitations of purely browser based code. You build it with HTML, place the file on each client's desktop or in a central file server folder they have access to and give them a shortcut to it. The application loads in a psuedo-web browser window which uses IE but does not give them the toolbars.

Since it is a small number of people who will use it this sounds like a good solution for you and you can use Javascript and VBScript as you like and have the benefit of HTML code as well.


It's hard to think outside the box when I'm trapped in a cubicle.
 
Here is a trimmed down version of something I did a while back. It is usuing VBScript to read from the DB and Javascript to do on page functions like rebuilding the display div. This is more complex than it needs to be for what it does at the moment because I trimmed out a lot of other code to make the example simple.

Put in a path to your own access db file and modify the query to suit your table to pull a couple of fields and it outputs them to a table on the page.
Code:
<html>

<head>
   <HTA:APPLICATION
   ID = "oApp"
   APPLICATIONNAME = "MAC Metrics Report"
   BORDER = "thick"
   CAPTION = "yes"
   ICON = "Report.ico"
   SHOWINTASKBAR = "yes"
   SINGLEINSTANCE = "yes"
   SYSMENU = "yes"
   WINDOWSTATE = "normal"
   SCROLL = "yes"
   SCROLLFLAT = "yes"
   VERSION = "1.0"
   INNERBORDER = "yes"
   SELECTION = "no"
   MAXIMIZEBUTTON = "yes"
   MINIMIZEBUTTON = "yes"
   NAVIGABLE = "yes"
   CONTEXTMENU = "yes"
   BORDERSTYLE = "normal"
   >

<title>Report</title>

<script language="vbscript">
Dim reportstyle
Dim uppertable
Dim lowertable
FUnction RunReport()
  Dim mytable
  mytable="<table border='0' cellspacing='0' cellpadding='0'>"

' Method 1
  Set Conn = CreateObject("ADODB.Connection")
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\mysever\myfolder\mydb.mdb;Persist Security Info=False"  
  Conn.Open ConStr

' Method 2 - In case method 1 does not work based on provider drivers available on PC.
'  Set Conn = CreateObject("ADODB.Connection")
'  Conn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=\\mysever\myfolder\mydb.mdb;Uid=admin;Pwd="

  SQLQuery = "Select FirstName, LastName From MyTable"
  Set rs = Conn.Execute(SQLQuery)

  do  until rs.eof 
    mytable=mytable&"<tr><td>" & rs("FirstName") & "</td><td>" & rs("LastName") & "</td></tr>"
    rs.movenext
  loop

  Conn.close
  mytable=mytable&"</table>"

  RunReport = mytable

End Function

</script>

<script language="javascript">
function newreport(year)
{
  //rebuild and display div.
  var mydiv = document.getElementById('MyReport');
  var outstr = RunReport();
  mydiv.style.visibility = "visible";
  mydiv.style.display = 'none';
  mydiv.innerHTML = outstr;
  mydiv.style.display = 'inline';
}

</script>

</head>
<body onload="window.resizeTo 900, 600">

<form method='post' action='' NAME='buildreport'>
<div id="MyReport" name="MyReport"></div>
<br>
<br>
<center><input type='button' name='changeyear' value='Run Report' onclick='newreport()'></center>
</form>
</body>
</html>

Save this as a file on your desktop with a .hta extension.


It's hard to think outside the box when I'm trapped in a cubicle.
 
ok. I will experiment with it. I'll respond back asap.
 
The thing about doing it client-side is that every user is editing your database individually.

When you do it server-side every user is sending commands to the web application and the application is editing the database.[tt]
user 1 --------> |----------|
user 2 --------> | database |
user 3 --------> |----------|

vs.

user 1 --------> |----------| |----------|
user 2 --------> | web app | -------> | database |
user 3 --------> |----------| |----------|
[/tt]

This is a particular problem with file-based databases like MS Access where everyone needs to edit the *.mdb file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top