ASP pages (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Toolman -> ASP pages (7/11/2002 9:34:19)

Is it possible to use the .asp page generated by frontpage to directly update the source database table for that page?

I have a database of names and addresses that i need to be able to update via a web page.
I have used the frontpage database results wizard to display the information in text boxes on a web page but now need to be able to amend that data within the text boxes and write it back to the same table in the database.

Any suggestions would be great.

Thanks in advance[:)]





rdouglass -> RE: ASP pages (7/11/2002 10:33:03)

Not in it' s ' native' form. You can however create a second page (using the DRW) and put in a custom script (for updating) on that second page. Once the update is done, you can redirect back to the first page. You can see the update instructions here:

http://www.outfront.net/spooky/update.htm

To do it all on the same page (at least AFAIK), you' ll have to do some custom ASP scripting.




Toolman -> RE: ASP pages (7/12/2002 6:57:38)

rdouglass

Thanks for the reply
I have taken a look at the instructions.
Unfortunately I cannot get it to connect to the database with the SQL code quoted on the web page (suitably modified to look at my own table headings).
I assume that this code is inserted in the second page of the wizard under the ' custom query' button or have I lost the plot completely[&:]

Cheers




Eli -> RE: ASP pages (7/12/2002 11:22:14)

post your code and we' ll see whats up




Toolman -> RE: ASP pages (7/12/2002 12:02:03)

Micah
Here goes.
I have managed to create a connection to the database using the wizard and the custom script that rdouglas suggested however it will not update the database table.

The code for the asp page is as follows:


<html>

<head>
<meta http-equiv=" Content-Type" content=" text/html; charset=windows-1252" >
<meta name=" GENERATOR" content=" Microsoft FrontPage 4.0" >
<meta name=" ProgId" content=" FrontPage.Editor.Document" >
<title>Cost</title>
</head>

<body>

<form BOTID=" 0" METHOD=" POST" ACTION=" orange_update.asp" >
<table BORDER=" 0" >
<tr>
<td><b>Cost_centre</b></td>
<td><input TYPE=" TEXT" NAME=" Cost_centre" VALUE=" <%=Request(" Cost_centre" )%>" size=" 20" ></td>
</tr>
<tr>
<td><b>ID</b></td>
<td><input TYPE=" TEXT" NAME=" ID" VALUE=" <%=Request(" ID" )%>" size=" 20" ></td>
</tr>
</table>
<br>
<input TYPE=" Submit" ><input TYPE=" Reset" ><!--webbot bot=" SaveAsASP" CLIENTSIDE
SuggestedExt=" asp" PREVIEW=" " -->
<p> </p>
</form>
<table width=" 100%" border=" 1" >
<thead>
</thead>
<tbody>
<!--webbot bot=" DatabaseRegionStart" startspan s-columnnames s-columntypes
s-dataconnection=" orangebilling" b-tableformat=" TRUE" b-menuformat=" FALSE"
s-menuchoice s-menuvalue b-tableborder=" TRUE" b-tableexpand=" TRUE"
b-tableheader=" TRUE" b-listlabels=" TRUE" b-listseparator=" TRUE"
i-ListFormat=" 0" b-makeform=" TRUE" s-recordsource s-displaycolumns
s-criteria s-order
s-sql=" UPDATE Cost_Centre<br>Set Field =' ::Cost_centre::' <br>WHERE ID=' ::ID::' "
b-procedure=" FALSE" clientside SuggestedExt=" asp"
s-DefaultFields=" Cost_centre=&amp;ID="
s-NoRecordsFound=" No records returned." i-MaxRecords=" 256" i-GroupSize=" 5"
BOTID=" 0" u-dblib=" _fpclass/fpdblib.inc" u-dbrgn1=" _fpclass/fpdbrgn1.inc"
u-dbrgn2=" _fpclass/fpdbrgn2.inc" tag=" TBODY"
local_preview=" <tr><td colspan=64 bgcolor=" #FFFF00" align=" left" width=" 100%" ><font color=" #000000" >Database Results regions will not preview unless this page is fetched from a Web server with a web browser. The following table row will repeat once for every record returned by the query.</font></td></tr>"
preview=" <tr><td colspan=64 bgcolor=" #FFFF00" align=" left" width=" 100%" ><font color=" #000000" >This is the start of a Database Results region. The page must be fetched from a web server with a web browser to display correctly; the current web is stored on your local disk or network.</font></td></tr>"
b-WasTableFormat=" TRUE" --><!--#include file=" _fpclass/fpdblib.inc" -->
<%
fp_sQry=" UPDATE Cost_Centre Set Field =' ::Cost_centre::' WHERE ID=' ::ID::' "
fp_sDefault=" Cost_centre=&ID="
fp_sNoRecords=" <tr><td colspan=16 align=left width=" " 100%" " >No records returned.</td></tr>"
fp_sDataConn=" orangebilling"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=" "
fp_sMenuValue=" "
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file=" _fpclass/fpdbrgn1.inc" -->
<!--webbot bot=" DatabaseRegionStart" i-CheckSum=" 59263" endspan -->
<!--webbot bot=" DatabaseRegionEnd" startspan b-tableformat=" TRUE"
b-menuformat=" FALSE" u-dbrgn2=" _fpclass/fpdbrgn2.inc" i-groupsize=" 5"
clientside tag=" TBODY"
local_preview=" <tr><td colspan=64 bgcolor=" #FFFF00" align=" left" width=" 100%" ><font color=" #000000" >This is the end of a Database Results region.</font></td></tr><TR><TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><FORM><NOBR><INPUT TYPE=Button VALUE=" |< " ><INPUT TYPE=Button VALUE=" < " ><INPUT TYPE=Button VALUE=" > " ><INPUT TYPE=Button VALUE=" >| " > [1/5]</NOBR></FORM></td></tr>"
preview=" <tr><td colspan=64 bgcolor=" #FFFF00" align=" left" width=" 100%" ><font color=" #000000" >This is the end of a Database Results region.</font></td></tr><TR><TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><NOBR><INPUT TYPE=Button VALUE=" |< " ><INPUT TYPE=Button VALUE=" < " ><INPUT TYPE=Button VALUE=" > " ><INPUT TYPE=Button VALUE=" >| " > [1/5]</NOBR><BR></td></tr>" --><!--#include file=" _fpclass/fpdbrgn2.inc" -->
<!--webbot bot=" DatabaseRegionEnd" i-CheckSum=" 62730" endspan -->
</tbody>
</table>

</body>

</html>


Thanks for taking the time to look[:)]







Spooky -> RE: ASP pages (7/12/2002 19:20:20)

I assume " ID" is numeric.
If so, then youll need to use :

 .... where ID = ::ID:: 


Numerics do not require the extra quotes as text do.




Toolman -> RE: ASP pages (7/13/2002 3:20:23)

Spooky
Thanks for the suggestion.
I have tried this both with and without the quotes.
I am getting the following error message on the web page when I try to run it :-



Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Number: -2147217904 (0x80040E10)
Source: Microsoft OLE DB Provider for ODBC Drivers


Cheers[:)]




Spooky -> RE: ASP pages (7/13/2002 8:11:17)

When you view the page, is the text box populated?

<input TYPE=" TEXT" NAME=" ID" VALUE=" <%=Request(" ID" )%>" size=" 20" >

If not, what is the link you use to get to this page?




Toolman -> RE: ASP pages (7/13/2002 8:34:25)

Spooky
Are you saying that I have to pass the data from another asp page to this one to populate the fields before I amend them and pass them to the database table?

This page when opened has empty text boxes. and an error mesage as follows:-


Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ' ID=' .
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

One or more form fields were empty. You should provide default values for all form fields that are used in the query.



Sorry to appear stupid but I am new to this and have very little HTML experience.

Many thanks[:)]




Spooky -> RE: RE: ASP pages (7/13/2002 8:47:50)

Ok, try this !

After the </form> tag, add this code :

</form>  
[color=red]<%If request(" ID" ) <> " "  then%>[/color]
 ....etc 

</table> 
[color=red]<%End if%>[/color]
</body> 





Toolman -> RE: ASP pages (7/13/2002 9:14:38)

Spooky
No change except that the text ....etc appears above the error box.[:(]

Cheers




Spooky -> RE: ASP pages (7/13/2002 12:02:55)

" ....etc" represents your code from the code you pasted above - you did include that?

You have used a query " where ID = ::ID::" ?




Toolman -> RE: ASP pages (7/15/2002 10:32:42)

Duh!
I seeeeee!
Like I said

quote:

Sorry to appear stupid but I am new to this and have very little HTML experience.


Ill give it another go.

Many thanks[:)]




Toolman -> RE: ASP pages (7/15/2002 10:42:53)

Spooky
Progress made!
The page no longer opens with an error but I still get the following when submitting the change to the database:-

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Number: -2147217904 (0x80040E10)
Source: Microsoft OLE DB Provider for ODBC Drivers

Do you know of an available example database and web pages that I can use as a basis for getting round my problem.
Perhaps if I can see one in action I can figure out where I am going wrong

Many thanks for your continued help[:D]





Spooky -> RE: ASP pages (7/15/2002 22:00:16)

Are the input boxes filled when you press submit?




Toolman -> RE: ASP pages (7/16/2002 2:37:27)

Spooky
Yes I enter the new value and click submit.
This gives the error message above.
I have checked that the ID I am using is in the database table.

Cheers[:)]




Spooky -> RE: ASP pages (7/16/2002 2:53:24)

Do you have an example URL perhaps? or how does the actual SQL string you use now look?




Toolman -> RE: ASP pages (7/16/2002 3:11:06)

No URL I' m afraid - this is for an intranet site and I am publishing this one to a test server at the side of my desk.

The SQL for this page is as follows:

UPDATE Cost_Centre
Set Field =' ::Cost_centre::'
WHERE ID=::ID::

Thanks for the continuing support[:)]




Spooky -> RE: ASP pages (7/17/2002 15:29:29)

With the code on a diet, can you change this code?

<% 
fp_sQry=" UPDATE Cost_Centre Set Field =' ::Cost_centre::'  WHERE ID=' ::ID::' "  
[color=#CC0000]Response.write fp_sQry
Response.end
[/color]
fp_sDefault=" Cost_centre=&ID="  


What is the result?




Toolman -> RE: ASP pages (7/19/2002 4:06:54)

Spooky
Sorry dont have time to try this at the moment as I am going on holiday for a fortnight.
I will try this when I get back and post the reply.

Many thanks[:D]




johnhbonds -> ASP pages (6/17/2003 18:04:22)

[:@]HOW WOULD I ENCOMPASS A FUNCTION IN MY ASP TO HAVE THE BACKGROUD OF A CELL IN A TABLE TO CHANGE COLORS, BASED ON IF THE COLOR IS NAMED ' G' FROM A COLUMN IN TABLE.

IF that isnt clear, I want the background to change green if G is the value on my table, yellow if Y is and so forth.

The tables name is projdate.


Thanks[:(]




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125