|
 |
asp_web_howto thread: Replacing html page with another html page
Message #1 by "Anthony Delcy" <DELCYAN@l...> on Fri, 23 Mar 2001 09:57:19 -0500
|
|
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
Message #2 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Fri, 23 Mar 2001 15:43:10 -0000
|
|
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
Message #3 by "Marcelo" <cyborg@m...> on Fri, 23 Mar 2001 12:58:54 -0300
|
|
please, explain it better...
as i undertsand, you RENDER a page on the fly....you want to change that
content once displayed?
triggered by what? if the update is triggered by some event, you can
simply refresh that page.
----- Original Message -----
From: Anthony Delcy <DELCYAN@l...>
To: ASP Web HowTo <asp_web_howto@p...>
Sent: Friday, March 23, 2001 8:50 PM
Subject: [asp_web_howto] Replacing html page with another html page
> Hi,
>
> I have a string "strHTML" which contains the information to build a html
> page from a .ASP page. What I want to happen is replace the current html
> page with the one I build on fly "strHTML".
>
> Right now it is just appending to the current html page which not what I
> want.
> When I say Response.Write strHTML I want to se my new page "the result of
> strHTML".
>
> Can anybody help me with this please.
>
> Thank you
>
> Anthony
>
>
>
> strHTML =3D ""
> strHTML =3D "<html>"
> strHTML =3D strHTML & "<HEAD>"
> strHTML =3D strHTML & "</HEAD>"
>
> strHTML =3D strHTML & "<body>"
> strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
> type=3Dtext/css >"
>
> strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
> cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1""
bordercolor=3D""stee
> lblue"" rules=3D""none"">"
> strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
> strHTML =3D strHTML & "<th colspan=3D""3""
class=3D""tblhdr"">Result</t
> h>"
> strHTML =3D strHTML & "</tr>"
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td width=3D""5""></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
> size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
> rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
> BORDER-TOP-STYLE: none""> "
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
> size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" &
rsXML("GTR_TITLE
> ") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
> size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" &
rsXML("GTR_P
> URPOSE") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
> size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" &
rsXML("PRODU
> CT_NUMBER") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
> size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" &
rsXML("TDPR_NUMBER
> ") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
> size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
> rsXML("PROJECT_NUMBER") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
> </td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
> size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
> rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
>
> strHTML =3D strHTML & "<tr>"
> strHTML =3D strHTML & "<td></td>"
> strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
> </td>"
> strHTML =3D strHTML & "<td>"
> strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
> size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
> rsXML("GTR_AREA") & "' readOnly>"
> strHTML =3D strHTML & "</td>"
> strHTML =3D strHTML & "</tr>"
> strHTML =3D strHTML & "</table>"
>
> strHTML =3D strHTML & "</body>"
> strHTML =3D strHTML & "</html>"
> =09
> Response.Write strHTML
> =09
> %>
>
>
Message #4 by "Anthony Delcy" <DELCYAN@l...> on Fri, 23 Mar 2001 11:56:40 -0500
|
|
Yes, that is exactly want I am trying to do.
Full detail :
I login if the user name and password are correct I then displace a html
page with some info. The user upades the information on the page if they
want and I write to the database when they click on update.
In my update .asp I insert the info in the database and come back and then
execute Select SQL to get the ID of the new info I just inserted. When I
returned with the ID I want to write it in the same htmp page in the first
text box but I tried and couldn't. So, I create another copy of the html
page with all the info from the other html page on fly. The result will be
the first html page does not have the ID number displayed but the second
html (copy of the first) will contain the ID number in the first text box.
These pages are being displayed in a VBA program through an OCX control
which I can then pick up the values from the html page and copy them to my
word document template.
Right now, it's doing I want except the last htm page with the ID number
is being appended below the first html page.
If you can show how to replace the previous html page that will do my day.
Thank you
Anthony
>>> "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> 03/23 10:43 AM
>>>
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one
ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
=3D
page from a .ASP page. What I want to happen is replace the current html
=3D
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
=3D
want.
When I say Response.Write strHTML I want to se my new page "the result of
=3D
strHTML".
Can anybody help me with this please. =3D20
Thank you
Anthony=3D20
strHTML =3D3D ""
strHTML =3D3D "<html>"
strHTML =3D3D strHTML & "<HEAD>"
strHTML =3D3D strHTML & "</HEAD>"
=3D20
strHTML =3D3D strHTML & "<body>"
strHTML =3D3D strHTML & "<LINK href=3D3D""GTR.css"" rel=3D3Dstylesheet
=3D
type=3D3Dtext/css >"
=3D20
strHTML =3D3D strHTML & "<table class=3D3D""tbl"" width=3D3D""600""
=3D
cellpadding=3D3D""0"" cellspacing=3D3D""0"" border=3D3D""1"" bordercolor=3D
3D""stee=3D
lblue"" rules=3D3D""none"">"
strHTML =3D3D strHTML & "<tr bgcolor=3D3D""steelblue"">"
strHTML =3D3D strHTML & "<th colspan=3D3D""3"" class=3D3D""tblhdr"">Res
ult</t=3D
h>"
strHTML =3D3D strHTML & "</tr>"
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td width=3D3D""5""></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
14"" =3D
size=3D3D""30"" id=3D3D""reportnumber"" name=3D3D""reportnumber""
value=3D3D'" & =3D
rsXML("GTR_NUMBER") & "' readOnly style=3D3D""BORDER-LEFT-STYLE: none; =3D
BORDER-TOP-STYLE: none""> "
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
40"" =3D
size=3D3D""80"" id=3D3D""title"" name=3D3D""title"" value=3D3D'" &
rsXML("GTR_TITLE=3D
") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
40"" =3D
size=3D3D""80"" id=3D3D""purpose"" name=3D3D""purpose"" value=3D3D'" &
rsXML("GTR_P=3D
URPOSE") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
40"" =3D
size=3D3D""80"" id=3D3D""product"" name=3D3D""product"" value=3D3D'" &
rsXML("PRODU=3D
CT_NUMBER") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
40"" =3D
size=3D3D""80"" id=3D3D""tdpr"" name=3D3D""tdpr"" value=3D3D'" & rsXML("TDP
R_NUMBER=3D
") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
40"" =3D
size=3D3D""80"" id=3D3D""projectnumber"" name=3D3D""projectnumber""
value=3D3D'" & =3D
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
=3D
</td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
40"" =3D
size=3D3D""80"" id=3D3D""changecontrol"" name=3D3D""changecontrol""
value=3D3D'" & =3D
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
=3D20
strHTML =3D3D strHTML & "<tr>"
strHTML =3D3D strHTML & "<td></td>"
strHTML =3D3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG> =3D
</td>"
strHTML =3D3D strHTML & "<td>"
strHTML =3D3D strHTML & "<input class=3D3D""editfld "" maxlength=3D3D""
1"" =3D
size=3D3D""1"" id=3D3D""sectionCode"" name=3D3D""sectionCode"" value=3D3D'"
& =3D
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D3D strHTML & "</td>"
strHTML =3D3D strHTML & "</tr>"
strHTML =3D3D strHTML & "</table>"
=3D20
strHTML =3D3D strHTML & "</body>"
strHTML =3D3D strHTML & "</html>"
=3D09
Response.Write strHTML
=3D09
%>
Message #5 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 26 Mar 2001 10:44:09 +0100
|
|
Why don't you just have them type their details into the form and then
submit?
You cant get rid of HTML once its been sent to the browser, and likewise you
can't control the browser from an ASP. All that you can do is sent a meta
refresh tag that would make the browser send out a new request.
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 4:57 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html page
Yes, that is exactly want I am trying to do.
Full detail :
I login if the user name and password are correct I then displace a html
page with some info. The user upades the information on the page if they
want and I write to the database when they click on update.
In my update .asp I insert the info in the database and come back and then
execute Select SQL to get the ID of the new info I just inserted. When I
returned with the ID I want to write it in the same htmp page in the first
text box but I tried and couldn't. So, I create another copy of the html
page with all the info from the other html page on fly. The result will be
the first html page does not have the ID number displayed but the second
html (copy of the first) will contain the ID number in the first text box.
These pages are being displayed in a VBA program through an OCX control
which I can then pick up the values from the html page and copy them to my
word document template.
Right now, it's doing I want except the last htm page with the ID number is
being appended below the first html page.
If you can show how to replace the previous html page that will do my day.
Thank you
Anthony
>>> "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> 03/23 10:43 AM
>>>
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
Message #6 by "Tim Morford" <tmorford@n...> on Mon, 26 Mar 2001 06:48:04 -0500
|
|
OK I looked around this is what I found on the gettting the new ID
How do I get the ID number of a just-inserted record? (6,254 requests)
SQL Server
With SQL Server 2000, there are a couple of new functions that are better
than @@IDENTITY. Both of these functions are not global to the connection,
which is an important weak point of @@IDENTITY. After doing an insert, you
can call:
PRINT IDENT_CURRENT('table')
This will give the most recent IDENTITY value for 'table' - regardless of
whether you created it or not (this overrides the connection limitation of
@@IDENTITY -- which can be useful).
Another thing you can do is:
PRINT SCOPE_IDENTITY()
This will give the IDENTITY value last created within the current stored
procedure, trigger, etc. One of the problems with the global nature of
@@IDENTITY is that if you do an INSERT, and that table has a TRIGGER ON
INSERT which then, in turn, inserts into another table with an IDENTITY
field, @@IDENTITY is populated with the second table's value.
If you are not using SQL Server 2000, the best way with SQL Server is to use
a single stored procedure that handles both the INSERT and the IDENTITY
retrieval using @@IDENTITY. Here is sample code for the stored procedure:
CREATE PROCEDURE myProc
@param1 INT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO someTable
(
intField
)
VALUES
(
@param1
)
SET NOCOUNT OFF
SELECT NEWID = @@IDENTITY
END
And you would call this from ASP as follows:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = conn.execute("exec myProc @param1=" & fakeValue)
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Access
With Access, you should be able to get away with something like this:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
conn.execute "Insert into someTable(intField) values(" & fakeValue & ")"
set rs = conn.execute("select MAX(ID) from someTable")
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Now I say "should" because it is (though very obscurely) possible for two
people to "cross" inserts, and receive the wrong autonumber value back. To
be frank, if there is a possibility of two or more people simultaneously
adding records, you should already be considering SQL Server (see FAQ #93).
However, if you're stuck with Access and need more security that this won't
happen, you can use a Recordset object with an adOpenKeyset cursor (this is
one of those rare scenarios where a Recordset object actually makes more
sense than a direct T-SQL statement):
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select [intField] from someTable where 1=0", conn, 1, 3
rs.AddNew
rs("intField") = fakeValue
rs.update
response.write "New ID was " & rs("id")
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
You can also look at Manohar's excellent articles at Active Server Corner:
http://www.kamath.com/tutorials/tut004_autonum.asp
http://www.kamath.com/tutorials/tut007_identity.asp
And check out MS' KB article:
http://support.microsoft.com/support/kb/articles/q221/9/31.asp
Now I imagin if you write this before the <HTML> you should be able to fill
the text box with the NEW ID
but I think you can use like a java script onError or onAbort purposy error
you DB and then have it auto fill the Text box that way
These are possable answers
what i would do is on the first page do a onSubmit then eather update or
insert the data in the database then on the second page have all the
information displayed if you want this done with one page you can use
<%select%> <%Case%> to submit the form to its self .. If you are using an
update you would already have the ID of the Fields already or you should ..
This is just my two cents .. i hope it helps and thanks to
http://www.aspfaq.com/faq/faqShow.asp?fid=74 for the article on the "How do
I get the ID number of a just-inserted record?"
-----Original Message-----
From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]
Sent: Monday, March 26, 2001 4:44 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
Why don't you just have them type their details into the form and then
submit?
You cant get rid of HTML once its been sent to the browser, and likewise you
can't control the browser from an ASP. All that you can do is sent a meta
refresh tag that would make the browser send out a new request.
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 4:57 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html page
Yes, that is exactly want I am trying to do.
Full detail :
I login if the user name and password are correct I then displace a html
page with some info. The user upades the information on the page if they
want and I write to the database when they click on update.
In my update .asp I insert the info in the database and come back and then
execute Select SQL to get the ID of the new info I just inserted. When I
returned with the ID I want to write it in the same htmp page in the first
text box but I tried and couldn't. So, I create another copy of the html
page with all the info from the other html page on fly. The result will be
the first html page does not have the ID number displayed but the second
html (copy of the first) will contain the ID number in the first text box.
These pages are being displayed in a VBA program through an OCX control
which I can then pick up the values from the html page and copy them to my
word document template.
Right now, it's doing I want except the last htm page with the ID number is
being appended below the first html page.
If you can show how to replace the previous html page that will do my day.
Thank you
Anthony
>>> "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> 03/23 10:43 AM
>>>
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
Message #7 by "O'Hara, Elliott M" <EMOHARA@k...> on Mon, 26 Mar 2001 07:05:39 -0500
|
|
if your auto incrementing your ID's
select max(ID) from yourtable
should do it fine
-----Original Message-----
From: Tim Morford [mailto:tmorford@n...]
Sent: Monday, March 26, 2001 6:48 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
OK I looked around this is what I found on the gettting the new ID
How do I get the ID number of a just-inserted record? (6,254 requests)
SQL Server
With SQL Server 2000, there are a couple of new functions that are better
than @@IDENTITY. Both of these functions are not global to the connection,
which is an important weak point of @@IDENTITY. After doing an insert, you
can call:
PRINT IDENT_CURRENT('table')
This will give the most recent IDENTITY value for 'table' - regardless of
whether you created it or not (this overrides the connection limitation of
@@IDENTITY -- which can be useful).
Another thing you can do is:
PRINT SCOPE_IDENTITY()
This will give the IDENTITY value last created within the current stored
procedure, trigger, etc. One of the problems with the global nature of
@@IDENTITY is that if you do an INSERT, and that table has a TRIGGER ON
INSERT which then, in turn, inserts into another table with an IDENTITY
field, @@IDENTITY is populated with the second table's value.
If you are not using SQL Server 2000, the best way with SQL Server is to use
a single stored procedure that handles both the INSERT and the IDENTITY
retrieval using @@IDENTITY. Here is sample code for the stored procedure:
CREATE PROCEDURE myProc
@param1 INT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO someTable
(
intField
)
VALUES
(
@param1
)
SET NOCOUNT OFF
SELECT NEWID = @@IDENTITY
END
And you would call this from ASP as follows:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = conn.execute("exec myProc @param1=" & fakeValue)
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Access
With Access, you should be able to get away with something like this:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
conn.execute "Insert into someTable(intField) values(" & fakeValue & ")"
set rs = conn.execute("select MAX(ID) from someTable")
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Now I say "should" because it is (though very obscurely) possible for two
people to "cross" inserts, and receive the wrong autonumber value back. To
be frank, if there is a possibility of two or more people simultaneously
adding records, you should already be considering SQL Server (see FAQ #93).
However, if you're stuck with Access and need more security that this won't
happen, you can use a Recordset object with an adOpenKeyset cursor (this is
one of those rare scenarios where a Recordset object actually makes more
sense than a direct T-SQL statement):
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select [intField] from someTable where 1=0", conn, 1, 3
rs.AddNew
rs("intField") = fakeValue
rs.update
response.write "New ID was " & rs("id")
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
You can also look at Manohar's excellent articles at Active Server Corner:
http://www.kamath.com/tutorials/tut004_autonum.asp
http://www.kamath.com/tutorials/tut007_identity.asp
And check out MS' KB article:
http://support.microsoft.com/support/kb/articles/q221/9/31.asp
Now I imagin if you write this before the <HTML> you should be able to fill
the text box with the NEW ID
but I think you can use like a java script onError or onAbort purposy error
you DB and then have it auto fill the Text box that way
These are possable answers
what i would do is on the first page do a onSubmit then eather update or
insert the data in the database then on the second page have all the
information displayed if you want this done with one page you can use
<%select%> <%Case%> to submit the form to its self .. If you are using an
update you would already have the ID of the Fields already or you should ..
This is just my two cents .. i hope it helps and thanks to
http://www.aspfaq.com/faq/faqShow.asp?fid=74 for the article on the "How do
I get the ID number of a just-inserted record?"
-----Original Message-----
From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]
Sent: Monday, March 26, 2001 4:44 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
Why don't you just have them type their details into the form and then
submit?
You cant get rid of HTML once its been sent to the browser, and likewise you
can't control the browser from an ASP. All that you can do is sent a meta
refresh tag that would make the browser send out a new request.
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 4:57 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html page
Yes, that is exactly want I am trying to do.
Full detail :
I login if the user name and password are correct I then displace a html
page with some info. The user upades the information on the page if they
want and I write to the database when they click on update.
In my update .asp I insert the info in the database and come back and then
execute Select SQL to get the ID of the new info I just inserted. When I
returned with the ID I want to write it in the same htmp page in the first
text box but I tried and couldn't. So, I create another copy of the html
page with all the info from the other html page on fly. The result will be
the first html page does not have the ID number displayed but the second
html (copy of the first) will contain the ID number in the first text box.
These pages are being displayed in a VBA program through an OCX control
which I can then pick up the values from the html page and copy them to my
word document template.
Right now, it's doing I want except the last htm page with the ID number is
being appended below the first html page.
If you can show how to replace the previous html page that will do my day.
Thank you
Anthony
>>> "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> 03/23 10:43 AM
>>>
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
Message #8 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 26 Mar 2001 13:28:52 +0100
|
|
If doing it this way make sure you use a transaction - otherwise if it is a
busy site its possible that someone esle could insert a record immediately
after you, and then when you do the select you will get their ID instead of
yours.
I would say that rather than using autonumber, it is far safer to assign the
ID yourself.
something like this:
set oConn = Server.CreateObject("ADODB.Connection")
oConn.open sDSN
oConn.beginTrans
sSQL = "SELECT MAX(ID) FROM table"
set oRS = oConn.execute(sSQL)
id = oRS(0) + 1
sSQL = "INSERT INTO table (ID, field1, field2) VALUES (" + id + ", " +
sData1 + ", " + sData2 + ")"
oConn.execute(sSQL)
oConn.commitTrans
Now the variable id contains the id
-----Original Message-----
From: O'Hara, Elliott M [mailto:EMOHARA@k...]
Sent: Monday, March 26, 2001 1:06 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
if your auto incrementing your ID's
select max(ID) from yourtable
should do it fine
-----Original Message-----
From: Tim Morford [mailto:tmorford@n...]
Sent: Monday, March 26, 2001 6:48 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
OK I looked around this is what I found on the gettting the new ID
How do I get the ID number of a just-inserted record? (6,254 requests)
SQL Server
With SQL Server 2000, there are a couple of new functions that are better
than @@IDENTITY. Both of these functions are not global to the connection,
which is an important weak point of @@IDENTITY. After doing an insert, you
can call:
PRINT IDENT_CURRENT('table')
This will give the most recent IDENTITY value for 'table' - regardless of
whether you created it or not (this overrides the connection limitation of
@@IDENTITY -- which can be useful).
Another thing you can do is:
PRINT SCOPE_IDENTITY()
This will give the IDENTITY value last created within the current stored
procedure, trigger, etc. One of the problems with the global nature of
@@IDENTITY is that if you do an INSERT, and that table has a TRIGGER ON
INSERT which then, in turn, inserts into another table with an IDENTITY
field, @@IDENTITY is populated with the second table's value.
If you are not using SQL Server 2000, the best way with SQL Server is to use
a single stored procedure that handles both the INSERT and the IDENTITY
retrieval using @@IDENTITY. Here is sample code for the stored procedure:
CREATE PROCEDURE myProc
@param1 INT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO someTable
(
intField
)
VALUES
(
@param1
)
SET NOCOUNT OFF
SELECT NEWID = @@IDENTITY
END
And you would call this from ASP as follows:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = conn.execute("exec myProc @param1=" & fakeValue)
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Access
With Access, you should be able to get away with something like this:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
conn.execute "Insert into someTable(intField) values(" & fakeValue & ")"
set rs = conn.execute("select MAX(ID) from someTable")
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Now I say "should" because it is (though very obscurely) possible for two
people to "cross" inserts, and receive the wrong autonumber value back. To
be frank, if there is a possibility of two or more people simultaneously
adding records, you should already be considering SQL Server (see FAQ #93).
However, if you're stuck with Access and need more security that this won't
happen, you can use a Recordset object with an adOpenKeyset cursor (this is
one of those rare scenarios where a Recordset object actually makes more
sense than a direct T-SQL statement):
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select [intField] from someTable where 1=0", conn, 1, 3
rs.AddNew
rs("intField") = fakeValue
rs.update
response.write "New ID was " & rs("id")
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
You can also look at Manohar's excellent articles at Active Server Corner:
http://www.kamath.com/tutorials/tut004_autonum.asp
http://www.kamath.com/tutorials/tut007_identity.asp
And check out MS' KB article:
http://support.microsoft.com/support/kb/articles/q221/9/31.asp
Now I imagin if you write this before the <HTML> you should be able to fill
the text box with the NEW ID
but I think you can use like a java script onError or onAbort purposy error
you DB and then have it auto fill the Text box that way
These are possable answers
what i would do is on the first page do a onSubmit then eather update or
insert the data in the database then on the second page have all the
information displayed if you want this done with one page you can use
<%select%> <%Case%> to submit the form to its self .. If you are using an
update you would already have the ID of the Fields already or you should ..
This is just my two cents .. i hope it helps and thanks to
http://www.aspfaq.com/faq/faqShow.asp?fid=74 for the article on the "How do
I get the ID number of a just-inserted record?"
-----Original Message-----
From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]
Sent: Monday, March 26, 2001 4:44 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
Why don't you just have them type their details into the form and then
submit?
You cant get rid of HTML once its been sent to the browser, and likewise you
can't control the browser from an ASP. All that you can do is sent a meta
refresh tag that would make the browser send out a new request.
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 4:57 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html page
Yes, that is exactly want I am trying to do.
Full detail :
I login if the user name and password are correct I then displace a html
page with some info. The user upades the information on the page if they
want and I write to the database when they click on update.
In my update .asp I insert the info in the database and come back and then
execute Select SQL to get the ID of the new info I just inserted. When I
returned with the ID I want to write it in the same htmp page in the first
text box but I tried and couldn't. So, I create another copy of the html
page with all the info from the other html page on fly. The result will be
the first html page does not have the ID number displayed but the second
html (copy of the first) will contain the ID number in the first text box.
These pages are being displayed in a VBA program through an OCX control
which I can then pick up the values from the html page and copy them to my
word document template.
Right now, it's doing I want except the last htm page with the ID number is
being appended below the first html page.
If you can show how to replace the previous html page that will do my day.
Thank you
Anthony
>>> "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> 03/23 10:43 AM
>>>
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
Message #9 by "O'Hara, Elliott M" <EMOHARA@k...> on Mon, 26 Mar 2001 08:30:29 -0500
|
|
nifty alex... i like it
-----Original Message-----
From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]
Sent: Monday, March 26, 2001 7:29 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
If doing it this way make sure you use a transaction - otherwise if it is a
busy site its possible that someone esle could insert a record immediately
after you, and then when you do the select you will get their ID instead of
yours.
I would say that rather than using autonumber, it is far safer to assign the
ID yourself.
something like this:
set oConn = Server.CreateObject("ADODB.Connection")
oConn.open sDSN
oConn.beginTrans
sSQL = "SELECT MAX(ID) FROM table"
set oRS = oConn.execute(sSQL)
id = oRS(0) + 1
sSQL = "INSERT INTO table (ID, field1, field2) VALUES (" + id + ", " +
sData1 + ", " + sData2 + ")"
oConn.execute(sSQL)
oConn.commitTrans
Now the variable id contains the id
-----Original Message-----
From: O'Hara, Elliott M [mailto:EMOHARA@k...]
Sent: Monday, March 26, 2001 1:06 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
if your auto incrementing your ID's
select max(ID) from yourtable
should do it fine
-----Original Message-----
From: Tim Morford [mailto:tmorford@n...]
Sent: Monday, March 26, 2001 6:48 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
OK I looked around this is what I found on the gettting the new ID
How do I get the ID number of a just-inserted record? (6,254 requests)
SQL Server
With SQL Server 2000, there are a couple of new functions that are better
than @@IDENTITY. Both of these functions are not global to the connection,
which is an important weak point of @@IDENTITY. After doing an insert, you
can call:
PRINT IDENT_CURRENT('table')
This will give the most recent IDENTITY value for 'table' - regardless of
whether you created it or not (this overrides the connection limitation of
@@IDENTITY -- which can be useful).
Another thing you can do is:
PRINT SCOPE_IDENTITY()
This will give the IDENTITY value last created within the current stored
procedure, trigger, etc. One of the problems with the global nature of
@@IDENTITY is that if you do an INSERT, and that table has a TRIGGER ON
INSERT which then, in turn, inserts into another table with an IDENTITY
field, @@IDENTITY is populated with the second table's value.
If you are not using SQL Server 2000, the best way with SQL Server is to use
a single stored procedure that handles both the INSERT and the IDENTITY
retrieval using @@IDENTITY. Here is sample code for the stored procedure:
CREATE PROCEDURE myProc
@param1 INT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO someTable
(
intField
)
VALUES
(
@param1
)
SET NOCOUNT OFF
SELECT NEWID = @@IDENTITY
END
And you would call this from ASP as follows:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = conn.execute("exec myProc @param1=" & fakeValue)
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Access
With Access, you should be able to get away with something like this:
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
conn.execute "Insert into someTable(intField) values(" & fakeValue & ")"
set rs = conn.execute("select MAX(ID) from someTable")
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Now I say "should" because it is (though very obscurely) possible for two
people to "cross" inserts, and receive the wrong autonumber value back. To
be frank, if there is a possibility of two or more people simultaneously
adding records, you should already be considering SQL Server (see FAQ #93).
However, if you're stuck with Access and need more security that this won't
happen, you can use a Recordset object with an adOpenKeyset cursor (this is
one of those rare scenarios where a Recordset object actually makes more
sense than a direct T-SQL statement):
<%
fakeValue = 5
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<conn string>"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select [intField] from someTable where 1=0", conn, 1, 3
rs.AddNew
rs("intField") = fakeValue
rs.update
response.write "New ID was " & rs("id")
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
You can also look at Manohar's excellent articles at Active Server Corner:
http://www.kamath.com/tutorials/tut004_autonum.asp
http://www.kamath.com/tutorials/tut007_identity.asp
And check out MS' KB article:
http://support.microsoft.com/support/kb/articles/q221/9/31.asp
Now I imagin if you write this before the <HTML> you should be able to fill
the text box with the NEW ID
but I think you can use like a java script onError or onAbort purposy error
you DB and then have it auto fill the Text box that way
These are possable answers
what i would do is on the first page do a onSubmit then eather update or
insert the data in the database then on the second page have all the
information displayed if you want this done with one page you can use
<%select%> <%Case%> to submit the form to its self .. If you are using an
update you would already have the ID of the Fields already or you should ..
This is just my two cents .. i hope it helps and thanks to
http://www.aspfaq.com/faq/faqShow.asp?fid=74 for the article on the "How do
I get the ID number of a just-inserted record?"
-----Original Message-----
From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]
Sent: Monday, March 26, 2001 4:44 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html pag e
Why don't you just have them type their details into the form and then
submit?
You cant get rid of HTML once its been sent to the browser, and likewise you
can't control the browser from an ASP. All that you can do is sent a meta
refresh tag that would make the browser send out a new request.
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 4:57 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Replacing html page with another html page
Yes, that is exactly want I am trying to do.
Full detail :
I login if the user name and password are correct I then displace a html
page with some info. The user upades the information on the page if they
want and I write to the database when they click on update.
In my update .asp I insert the info in the database and come back and then
execute Select SQL to get the ID of the new info I just inserted. When I
returned with the ID I want to write it in the same htmp page in the first
text box but I tried and couldn't. So, I create another copy of the html
page with all the info from the other html page on fly. The result will be
the first html page does not have the ID number displayed but the second
html (copy of the first) will contain the ID number in the first text box.
These pages are being displayed in a VBA program through an OCX control
which I can then pick up the values from the html page and copy them to my
word document template.
Right now, it's doing I want except the last htm page with the ID number is
being appended below the first html page.
If you can show how to replace the previous html page that will do my day.
Thank you
Anthony
>>> "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> 03/23 10:43 AM
>>>
Don't quite get what your trying to do... you've already written stuff to
the browser, then you want the contents of whats in the browser to be
replaced with the contents of strHTML? All during the execution of one ASP?
-----Original Message-----
From: Anthony Delcy [mailto:DELCYAN@l...]
Sent: Friday, March 23, 2001 11:50 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Replacing html page with another html page
Hi,
I have a string "strHTML" which contains the information to build a html
page from a .ASP page. What I want to happen is replace the current html
page with the one I build on fly "strHTML".
Right now it is just appending to the current html page which not what I
want.
When I say Response.Write strHTML I want to se my new page "the result of
strHTML".
Can anybody help me with this please.
Thank you
Anthony
strHTML =3D ""
strHTML =3D "<html>"
strHTML =3D strHTML & "<HEAD>"
strHTML =3D strHTML & "</HEAD>"
strHTML =3D strHTML & "<body>"
strHTML =3D strHTML & "<LINK href=3D""GTR.css"" rel=3Dstylesheet
type=3Dtext/css >"
strHTML =3D strHTML & "<table class=3D""tbl"" width=3D""600""
cellpadding=3D""0"" cellspacing=3D""0"" border=3D""1"" bordercolor=3D""stee
lblue"" rules=3D""none"">"
strHTML =3D strHTML & "<tr bgcolor=3D""steelblue"">"
strHTML =3D strHTML & "<th colspan=3D""3"" class=3D""tblhdr"">Result</t
h>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td width=3D""5""></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Report #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""14""
size=3D""30"" id=3D""reportnumber"" name=3D""reportnumber"" value=3D'" &
rsXML("GTR_NUMBER") & "' readOnly style=3D""BORDER-LEFT-STYLE: none;
BORDER-TOP-STYLE: none""> "
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Title</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""title"" name=3D""title"" value=3D'" & rsXML("GTR_TITLE
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Purpose</STRONG></td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""purpose"" name=3D""purpose"" value=3D'" & rsXML("GTR_P
URPOSE") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Product #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""product"" name=3D""product"" value=3D'" & rsXML("PRODU
CT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>TDPR #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""tdpr"" name=3D""tdpr"" value=3D'" & rsXML("TDPR_NUMBER
") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Project #</STRONG> </td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""projectnumber"" name=3D""projectnumber"" value=3D'" &
rsXML("PROJECT_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Change Control #</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""40""
size=3D""80"" id=3D""changecontrol"" name=3D""changecontrol"" value=3D'" &
rsXML("CHANGE_CONTROL_NUMBER") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "<tr>"
strHTML =3D strHTML & "<td></td>"
strHTML =3D strHTML & "<td NOWRAP><STRONG>Section Code</STRONG>
</td>"
strHTML =3D strHTML & "<td>"
strHTML =3D strHTML & "<input class=3D""editfld "" maxlength=3D""1""
size=3D""1"" id=3D""sectionCode"" name=3D""sectionCode"" value=3D'" &
rsXML("GTR_AREA") & "' readOnly>"
strHTML =3D strHTML & "</td>"
strHTML =3D strHTML & "</tr>"
strHTML =3D strHTML & "</table>"
strHTML =3D strHTML & "</body>"
strHTML =3D strHTML & "</html>"
=09
Response.Write strHTML
=09
%>
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
|
|
 |