Drew Wutka
DWUTKA at Marlow.com
Thu Feb 3 17:01:12 CST 2011
Not to mention that if she is running into problems with the current system, a 'canned' solution would most likely carry those same issues along with it. A long time ago, I built a 'canned' solution that would display reports from an access database across the web (and any 'UI' prompts, like [Enter Product Number] that were in the query would be read, recreated into a web format to be displayed to the user, and then the user's response sent back to the actual .mdb). It worked great. Toyed with the idea of doing the same for forms, and ran into a huge brick wall with how Access subclasses the windows in its forms. So I never took it any further. But to take an Access mdb, and just 'dump it' into a web application loses the benefit of some of the great features a web application can incorporate. For instance, if you were to just create a Dropdown box, that 'populated' some fields in an ASP.NET application, ASP.Net would let you make it 'look' like an access combobox, and act like it, but what's happening in the background is clunky. First, .Net is creating javascript on the client side that is reacting to the 'OnClick' of the combobox (or index changed event), then it's sending all the current web form info back to the server (as a PostBack), where the web server then does what your .Net (VB or C#) code wants to do, in filling in the fields, and sends all that back to the user. UGLY. Works, but ugly. If it's a huge form, or a very slow connection, that creates noticeable pauses and reloads on the web page. There is another solution: You can create a generic handler, that uses JQuery (AJAX) on the client side to just 'ask' the web server for the applicable data. Here's a generic handler (.ashx file) <%@ WebHandler Language="VB" Class="LoadDoctorInfo" %> Imports System Imports System.Web Public Class LoadDoctorInfo : Implements IHttpHandler Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim intID As String = context.Request.QueryString("DoctorID") Dim strDocInfo As New StringBuilder Dim dr As New Doctor(intID) strDocInfo.Append("[{""DoctorName"":""" & dr.Name & """,") strDocInfo.Append("""Address1"":""" & dr.Address1 & """,") strDocInfo.Append("""Address2"":""" & dr.Address2 & """,") strDocInfo.Append("""City"":""" & dr.City & """,") strDocInfo.Append("""State"":""" & dr.State & """,") strDocInfo.Append("""Zip"":""" & dr.ZipCode & """,") strDocInfo.Append("""Phone"":""" & dr.Phone & """}]") context.Response.ContentType = "application/json" context.Response.ContentEncoding = Encoding.UTF8 context.Response.Write(strDocInfo.ToString()) context.Response.End() End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class The above file is stored on the web server, and is called using the follow javascript on the client end: <asp:DropDownList ID="cmbDoctorAutoFill" runat="server"></asp:DropDownList> <script src="_scripts/jquery-1.2.6.js" type="text/javascript"></script> <script type="text/javascript" language="javascript"> $(document).ready(function () { $("#cmbDoctorAutoFill").change(function () { var JDoctorID = $("#cmbDoctorAutoFill > option[@selected]").attr("value"); if (JDoctorID != '') { $.getJSON('LoadDoctorInfo.ashx?DoctorID=' + JDoctorID, function (docinfo) { $.each(docinfo, function () { $("#txtDataDoctorName").val(this['DoctorName']); $("#txtDataDoctorAddress1").val(this['Address1']); $("#txtDataDoctorAddress2").val(this['Address2']); $("#txtDataDoctorCity").val(this['City']); $("#txtDataDoctorZip").val(this['Zip']); $("#txtDataDoctorPhoneNumber").val(this['Phone']); $("#cmbDataDoctorState").val(this['State']); }); }); } }); }); </script> The drop down list is filled with doctors and their IDs, the jquery-1.2.6.js file (which you can download from the web) has all the code necessary to make the above code work. It takes the ID of the combo, queries the webserver's generic handler ('LoadDoctorInfo.ashx') and then populates controls on the end user's form using data from what's returned by the handler. The user's form doesn't have to 'reload' against the webserver, and that interaction 'appears' to work just like a combo box on an Access form would work. There are several other tricks you can do with .asp pages which will help increase the performance of an application. While there may be 'canned' apps out there, which can stuff an application into a .Net solution, I doubt it will be very finely tuned or optimized. Heck, one of the features of ASP.Net that I fell in love with, is how easy it is to create a 'downloaded file' on the fly. (Say on a data form, you want to give the user the ability to download a .csv file of the data they are working on, with .asp, I would create the .csv file in a temp file, and then redirect them to that file... with ASP.Net, it's extremely easy to just interrupt the outbound feed, and just send the file on the fly. Probably could have done that in classic asp, but the tutorial to do that in asp.Net was quick and easy to find). No more temp files. Very slick. Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, January 31, 2011 7:51 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] From a reader Darryl -- I agree. She's looking for a canned solution and I've told her there isn't any such thing -- but I thought I'd ask. You never know. :) Susan H. The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.