473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using Access As a web database

68
I have an Access database that I want to connect to some forms that i created in Frontpage. I dont have a clue of where to start. Can anybody help or point me to a simple tutorial.
Thank You
May 12 '08 #1
10 1798
jeffstl
432 Expert 256MB
I have an Access database that I want to connect to some forms that i created in Frontpage. I dont have a clue of where to start. Can anybody help or point me to a simple tutorial.
Thank You
Classic ASP

You need to set up a connection string, and use asp variables to load data into your form.

You will also need to use an SQL querystring to pull data from your database.

Try some things out. If you have specific problems post them in the ASP forum as you run into them and I can keep helping you out.
May 12 '08 #2
KingKen
68
Ok i search and found some tutorials, got some stuff going but is stuck at the following error

Microsoft JET Database Engine error '80040e14'

Syntax error. in query expression 'SELECT [Maintenance_History].HardwareAssetID'.

/DMS/Update.asp, line 25


I am calling the following codes from a form that i entered information

<HTML><HEAD><TITLE>Added Page</TITLE></HEAD>
<BODY BGCOLOR=#ffffff MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN=0 TOPMARGIN=0>
<%
Dim DataConnection
Dim RsAddRecords
Dim strSQL

'Open the database connection
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& Server.MapPath("/DMS/testBase.mdb"))

'Create an ADO recordset object
Set RsAddRecords = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT SELECT [Maintenance_History].HardwareAssetID, [Maintenance_History].DateReported, [Maintenance_History].ProblemDescription, [Maintenance_History].Cause, [Maintenance_History].SolutionDescription, [Maintenance_History].PerformedBy, [Maintenance_History].DateCompleted, [Maintenance_History].Comments, [Maintenance_History].Department, [Maintenance_History].Status FROM [Maintenance_History];"

'Set the cursor type we are using so we can navigate through the recordset
RsAddRecords.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
RsAddRecords.LockType = 3

'Open the recordset with the SQL query
RsAddRecords.Open strSQL, DataConnection

'Tell the recordset we are adding a new record to it
RsAddRecords.AddNew

'Add a new record to the recordset
RsAddRecords.Fields("HardwareAssetID") = Request.Form("Asset_ID")
RsAddRecords.Fields("DateReported") = Request.Form("Date_Reported")
RsAddRecords.Fields("ProblemDescription") = Request.Form("Issue_Reported")
RsAddRecords.Fields("Cause") = Request.Form("Cause")
RsAddRecords.Fields("SolutionDescription") = Request.Form("Action_Taken")
RsAddRecords.Fields("PerformedBy") = Request.Form("Serviced_By")
RsAddRecords.Fields("DateCompleted") = Request.Form("Date_Completed")
RsAddRecords.Fields("Comments") = Request.Form("Comments")
RsAddRecords.Fields("Department") = Request.Form("Department")
RsAddRecords.Fields("Status") = Request.Form("Status")


'Write the updated recordset to the database
RsAddRecords.Update

'Reset server objects
RsAddRecords.Close
Set RsAddRecords = Nothing
Set DataConnection = Nothing
%>

<p align="center">&nbsp;<p align="center">Data was successfully added<p align="center">&nbsp;<p align="center">
</BODY>
</HTML>
May 15 '08 #3
jeffstl
432 Expert 256MB
You have 2 SELECTS. You only need 1. There could be more issues with your SQL but try that first

Expand|Select|Wrap|Line Numbers
  1. 'take out one of the SELECT
  2. strSQL = "SELECT [Maintenance_History].HardwareAssetID, [Maintenance_History].DateReported, [Maintenance_History].ProblemDescription, [Maintenance_History].Cause, [Maintenance_History].SolutionDescription, [Maintenance_History].PerformedBy, [Maintenance_History].DateCompleted, [Maintenance_History].Comments, [Maintenance_History].Department, [Maintenance_History].Status FROM [Maintenance_History];" 
  3.  
Also since you are only querying 1 table you really dont need to specify the table in the SQL. In fact you might even be able to just do this:

Expand|Select|Wrap|Line Numbers
  1. 'take out one of the SELECT
  2. strSQL = "SELECT * FROM Maintenance_History" 
  3.  
May 15 '08 #4
KingKen
68
hey i found the error... Look at the SQL statement and you'll see two SELECT. there should only be one.
I do hope that this post help someone.
I'll probably be calling for some more help soon so please stay tune
May 15 '08 #5
KingKen
68
I want to create a form to search the database for any record the user might need to see. the idea here is that the user would select the table he want to search then based on that selection the field combo box would be filled with the appropriate fields. I haven't a clue on how to accomplish this but i know that i need to do it to make make searching a breeze.

Help please.

Expand|Select|Wrap|Line Numbers
  1. <form method="POST" action=search.asp>
  2.             <p align="center"><b>
  3.             <font color="#000080" face="Poor Richard" size="5">Table</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  4.             <select size="1" name="Table">
  5.             <option>Adapters/Cards</option>
  6.             <option>AdapterCards/Subform</option>
  7.             <option>Hardware Assets</option>
  8.             <option>Internal Drives</option>
  9.             <option>internaldrives/subform</option>
  10.             <option>Maintenance History</option>
  11.             <option>Ssupportlogs</option>
  12.             </select></p>
  13.             <p align="center"><b><font size="5" color="#000080">Fields<select size="1" name="Field">
  14.             </select></font></b></p>
  15.             <p align="center"><b>
  16.             <font color="#000080" face="Poor Richard" size="5">Content</font></b>
  17.             <input type="text" name="Search" size="38" tabindex="1"></p>
  18.             <p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  19.             <font size="3">
  20.             <input type="submit" value="Search" name="Submit" tabindex="2" style="font-weight: 700"></font></p>
  21.         </form>
May 19 '08 #6
jeffstl
432 Expert 256MB
Are you talking about doing this in the local users browser?

For example they select something from a drop down and the next drop down is instantly populated ? You may need to use javascript to have that happen and the values of the drop downs would have to be hard coded into the HTML.

Not sure how you plan to do this as far as process. (Could be javascript, could be submission to the "next" page via asp. Going to depend alot on that.

Here is some ASP on listing column names in a record set though (That you could get by querying one of your tables).

Expand|Select|Wrap|Line Numbers
  1. for each f in RS.Fields
  2.    Response.Write(f.Name & "<br>")
  3. next
  4.  
May 19 '08 #7
KingKen
68
I thought of it as being done in the user browser where i hardcode the field names after which i'll pass the request to the an asp page which would search the specified table field for the relavant data.
May 19 '08 #8
jeffstl
432 Expert 256MB
I thought of it as being done in the user browser where i hardcode the field names after which i'll pass the request to the an asp page which would search the specified table field for the relavant data.
What I was just trying to say was that if you want to choose a table, then have a Second drop down list populate with the columns from that table without a reload of the page you would need to use javascript.

Ok. However if you are not using the database to pull your field names (using below code from a recordset) from if anything ever changes, keep in mind you will also then have to change your asp page <option> values.
Expand|Select|Wrap|Line Numbers
  1. for each f in RS.Fields
  2.    Response.Write("<option>" & f.Name & "</option>")
  3. next
  4.  
In that case though since you just want to grab a value from a form this should be relatively simple.

On your search.asp page simply get the values of the combo box's into an SQL string that produces the search results. The below code assumes you have a connection string already set up.

Expand|Select|Wrap|Line Numbers
  1. 'for search.asp
  2. dim MyTable,StrSQL
  3. dim MyRS
  4. Set MyRS = server.CreateObject("Adodb.Recordset")
  5. MyTable = request.form("Table") 'this is your combo box (drop down)
  6. StrSQL = "Select * from " & MyTable & ""
  7. MyRS.Open strSQL, DataConnection
  8.  
  9.  
Is this what you mean?
May 19 '08 #9
KingKen
68
I do appriciate you responding promptly to my post with insightfull help and ideas.

The java script function is what i think i need help with. If you noticed in the html codes i sent, there are two combo boxes; one named table which holds the tables in the db and the other named fields which should hold the fields in the selected table only. i want to select a table and have a script deliver the fields straight to combo box where i can then select the field, type the search text and click submit to call the search.asp page to do it's thing.
the function should do client side processing rather than server side
May 19 '08 #10
jeffstl
432 Expert 256MB
Ok. Well that is a javascript function that is available in a few places. This is one I have used alot that is an excellent example of how to do something like that.

Javascript Kit Drop Down Example

Here is the modified version of that showing how you would use it. Be aware however that this example is set up to redirect the user on the last selection to a website value. Instead just have your button click submit the form.
Expand|Select|Wrap|Line Numbers
  1. <form name="MyForm">
  2. <select name="MyTables" size="1" onChange="displaysub()">
  3. <option value="#">This is a place Holder text </option>
  4. </select>
  5. <input type="button" name="test" value="Go!"
  6. onClick="gothere()">
  7. </form>
  8.  
  9. <script>
  10. <!--
  11.  
  12. //MAIN DROP DOWN
  13.  
  14. var category=new Array()
  15. category[0]=new Option("SELECT A TABLE ", "") 
  16. category[1]=new Option("TABLE1 NAME", "combo1")
  17. category[2]=new Option("TABLE2 NAME", "combo2")
  18. category[3]=new Option("TABLE3 NAME", "combo3")
  19.  
  20. //SUB DROP DOWNS
  21.  
  22. var combo1=new Array()
  23. combo1[0]=new Option("COLUMN NAME FROM TABLE 1","WHATEVERVALUE")
  24. combo1[1]=new Option("BACK TO TABLES","")   
  25.  
  26. var combo2=new Array()
  27. combo2[0]=new Option("COLUMN NAME FROM TABLE 2","WHATEVERVALUE")
  28. combo2[1]=new Option("BACK TO TABLES","")  
  29.  
  30. var combo3=new Array()
  31. combo3[0]=new Option("COLUMN NAME FROM TABLE 3","WHATEVERVALUE")
  32. combo3[1]=new Option("BACK TO TABLES","")  
  33.  
  34. var curlevel=1
  35. var cacheobj=document.MyForm.MyTables
  36.  
  37. function populate(x){
  38. for (m=cacheobj.options.length-1;m>0;m--)
  39. cacheobj.options[m]=null
  40. selectedarray=eval(x)
  41. for (i=0;i<selectedarray.length;i++)
  42. cacheobj.options[i]=new Option(selectedarray[i].text,selectedarray[i].value)
  43. cacheobj.options[0].selected=true
  44.  
  45. }
  46.  
  47. function displaysub(){
  48. if (curlevel==1){
  49. populate(cacheobj.options[cacheobj.selectedIndex].value)
  50. curlevel=2
  51. }
  52. else
  53. gothere()
  54. }
  55.  
  56.  
  57. function gothere(){
  58. if (curlevel==2){
  59. if (cacheobj.selectedIndex==cacheobj.options.length-1){
  60. curlevel=1
  61. populate(category)
  62. }
  63. else
  64. location=cacheobj.options[cacheobj.selectedIndex].value
  65. }
  66. }
  67.  
  68. populate(category)
  69.  
  70. //-->
  71. </script>
  72.  
May 19 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

38
by: Remco Groot Beumer | last post by:
Hello, I'm trying to decide if the following situation would be workable: Generate an MS Access Front End (which will run localy on client computers), which will link to a DBMS (SQL server or...
5
by: dananrg | last post by:
I've created a small company database where the tables reside in a SQL Server database. I'm using Access 2000 forms for a front end. I've got a System DSN set-up to SQL Server and am using links...
1
by: Matt Alanzo | last post by:
On another newsgroup an Access knowledgable party posted: >You should be able to connect an Access ADP to an existing SQLExpress >database running in SQLS 2000 compatibility mode. The only thing...
10
by: B Moor | last post by:
Host PC: Win SBS 2003 with 2.6 GHz processor and 1GB RAM SQL Server 2000 sp3 (or latest).MS Office 2k3 I have the access 2k3 front end running on server (this may get changed) and all was well...
8
by: Carl | last post by:
Hi, Using MS Access 2000, is it possible to run a UPDATE or INSERT SQL query using some form of conditional IF THEN ?? for example: SELECT * FROM Books IF EXISTS(Select Books.ID = 1)
6
by: Serious_Practitioner | last post by:
Good day all, and thank you in advance for your help. No - MANY thanks in advance for your help - I know nothing about using databases on Web servers. I am about to discuss a project with a...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
4
by: Bugs | last post by:
Hi everyone. I am trying to open a database which works fine using Access 2003, but when trying to open it on another PC that has Access 2002 I get the following error "This database is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.