borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Doing a post to a browser using VB)Next Topic (HTML-based Cataloguer?) New Topic New Poll Post Reply
AndreaVB Forum : Internet Applications : MS Access & ASP?
Poster Message
victorypoint
Level: Guest


icon MS Access & ASP?

Thanks to everyone who helped me on my first post.

I need to create a webpage generated from live data located in a few MS Access 2000 tables.  The webpage prompts for a login (username and passwords are in one Access table).  Once logged in, the webpage displays a report that closely resembles an Access report already defined in the same MDB.

Is it possible to simply create an HTML page from an Access report or does the page need to be designed from scratch in Visual Studio or other another tool?

Any help is greatly appreciated.
Regards,
-Alan

28-01-2003 at 08:20 PM
| Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: MS Access & ASP?

i'm not sure about creating from the reports, but i do know how to create them from the tables... yep, asp is the way to go here...

<%@ LANGUAGE = "VBSCRIPT" %>
<% OPTION EXPLICIT %>
<html>
<head><TITLE>Recordset Paging</TITLE>
</head>
<body>
<div align="center">
<table width="600">
<tr>
<td width="450" valign="top"
  <%
      Dim databaseConnection, openDatabase
      Set databaseConnection=Server.CreateObject("ADODB.Connection")
      openDatabase="driver={Microsoft Access Driver (*.mdb)};" & _
              "dbq=" & Server.MapPath("database.mdb")
      databaseConnection.Open openDatabase

      Dim CurPage, records, RowCount, i, PageChoice
      CurPage = Request.QueryString("page")
      If CurPage = "" Then CurPage = 1
      Set records = Server.CreateObject("ADODB.Recordset")
      records.CursorType = 3
      PageChoice = Request.QueryString("PageChoice")
      If PageChoice = "" Then
      records.PageSize = 5
      Else
      records.PageSize = PageChoice
      End If
      records.Open "SELECT field1, field2, field3 FROM fields", databaseConnection
      records.AbsolutePage = CInt(CurPage)
      RowCount = 0
   %>
<table border = "1">
<tr>
<td>field1</td>
<td>field2</td>
<td>field3</td>
</tr>
   <% WHILE NOT records.EOF and RowCount < records.PageSize %>
<tr>
<td><%= records("field1") %> </td>
<td><%= records("field2") %> </td>
<td><%= records("field3") %> </td>
</tr>
<%
RowCount = RowCount + 1
records.MoveNext
   Wend
   %>
</table>
<p>Jump to page:
<% For i = 1 to records.PageCount %>
<a href="paging.asp?page=<%=i%>&PageChoice=<%=PageChoice%>"><%=i%></a> 
<% Next %>
</p>
<form action="paging.asp?page=1" name="rows" method="get">
How many Records per Page? <select name="PageChoice">
<option value="5">5</option>
<option value="7">7</option>
<option value="10">10</option>
</select>
<input type="submit" value="Submit">
</form>
<%
records.Close
Set records = Nothing
databaseConnection.Close
Set databaseConnection = Nothing
%>
</td>
</tr>
</table>
</div>
</body>
</html>


i don't remember where i first got this, since it was a long time ago, but if a report is whatyou want to show, then this might do...

[Edited by vbgen on 29-01-2003 at 01:29 PM GMT]

____________________________
Been busy trying to take a second degree <--it's not working out...

29-01-2003 at 05:27 AM
View Profile Send Email to User Show All Posts | Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Login Page

i believe this came from grassstable (a programmer)

*** Simply add this include statement as the first line to any page you want password protected...

<!--#include file="checklogin.asp"-->


*** checklogin.asp ***
*** This file check to see if you have logged in. If you have not, it will redirect you to the log
*** in page. If you have logged in, you'll continue to load the rest of the requested page.

<%
'This will keep the requested page in the address bar.
if not (Session("BGS Member") = "BGS Member" and Session("alyssa") = "alyssa") then
Server.Transfer("Members Please Sign In")
end if
%>

*** login.asp ***
*** This is the page which you will be redirected to if your log in failed or was timed out.

<html>
<body>

<%
'if the form was filled out, set the session variables
if not Request.Form("BGS Member") = "" then
Session("BGS") = Request.Form("BGS Member")
Session("alyssa") = Request.Form("alyssa")
end if

'if the session variable do not match the username/password combo, show the log in form
if not (Session("BGS Member") = "BGS Member" and Session("alyssa") = "alyssa") then
%>

<form name="BGS Member Sign In" method="post" autocomplete="off">
  <p align="center"><font size="5">Please Log In</century Gothic></p>
  <p>Username: <input type="century gothic" name="BGS Member"></p>
  <p>Password: <input type="password" name="password"></p>
  <p>
    <input type="BGS Member" name="BGS Member" value="BGS Member">
    <input type="reset" name="Reset" value="Reset">
  </p>
</form>

<% else %>

<!-- Log in succeeded -->
<p align="center"><font size="5">Thank You</Century Gothic></p>

<p>
Thanks for logging in. You are authorized to access private
sections of this web site. You may either
<a href="<%=Request.ServerVariables(" http://horseylover14.tripod.com/presenting/
")%>">refresh</a>
this page or go to the
<a href="admin.asp">Administration Area</a>.
</p>

<% end if %>

</body>
</html>


IF THAT'S CONFUSING, TRY THIS NEXT ONE

i found this just now.

<HEAD>

<SCRIPT LANGUAGE="sx - sCRIPTS">

<!-- Jeremy Rathburns New login Script -->

<!-- Begin
function Login(form) {
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
if (username && password && server) {
var htsite = "http://YOUR_SITE_HERE.com/" + MEMBERS-AREA + "/" + USERNAME + "/" + PASSWORD + "." + "html";
window.location = htsite;
}
else {
alert("Please enter your username and password.");
   }
}
//  End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<!-- The hidden form field "server" needs to be the
     address of your password protected directory. -->

<form name=login>
<input type="hidden" name="server" value="SITHYX.com">
Username:
<input type=text name=username size=20>
<br><br>
Password:
<input type=password name=password size=20>
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</form>


____________________________
Been busy trying to take a second degree <--it's not working out...

29-01-2003 at 05:47 AM
View Profile Send Email to User Show All Posts | Quote Reply
victorypoint
Level: Guest

icon Re: MS Access & ASP?

Thanks for the ASP code vbgen.  The paging.asp script looks good.  I just have to figure out how to change it to work with my Access database.  Do you know how to modify it to work with an ODBC System DSN or without ODBC at all?

-Alan

29-01-2003 at 04:25 PM
| Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: ODBC

i'm sorry, victorypoint...

using the db connection is all i know at this point... it's because i'm trying to study the methods available to me for my thesis...

sorry... but won't this code work for you? or are you trying to expand your knowledge?

well, good luck, and stay active here at andreavb forum, okay?   

____________________________
Been busy trying to take a second degree <--it's not working out...

29-01-2003 at 06:35 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Internet Applications : MS Access & ASP?
Previous Topic (Doing a post to a browser using VB)Next Topic (HTML-based Cataloguer?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder