I am attempting to retrieve a value from a database and populate a
textbox on my html form. This code appears to run fine without error
but i do not get any value in my textbox. Im very new to ASP and im
having to change an existing system. If i do not put my vbscript code
at the bottom of the screen then my page will not render correctly.
Can anyone please help me ??? Are there any major flaws with my code
??? should my script be before my textbox ???? by the way im only
hardcoding input values for test purposes.

<%@ Language=vbscript LCID=2057%>
<HTML>
<HEAD>
<title>IDD Document</title>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING="GridLayout" bgcolor="#ffdcff">


<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 102; LEFT: 0px; POSITION: absolute;
TOP: 0px" cellSpacing="0"cellPadding="0" width="100%" border="0"
height="100%">
<TBODY>
<TR>
<TD style="HEIGHT: 42px" vAlign="top">
<BR>
<INPUT id="btn_BackToMenu" type="button" value="Close Window"
onclick="window.close()" runat="server"></TD>

*******************************************************************
*******************TEXT BOX I WANT TO POPULATE*********************

<input type="text" name="T1" size="20" value="<%= strtext%>"

*******************************************************************
*******************************************************************

</TR>
<TR>

<TD><iframe name="myIframe" height="100%" width="100%"
frameborder=no src="documents/IDD.pdf" </TR>
</td></form>

</TABLE>
</form>
</body></IFRAME></TR></TBODY></TABLE></FORM>
*****************************************************************************
******************VBSCRIPT CODE********************************
*****************************************************************************
<%

Dim oRS, strSQL, txt_ClientCode, strtext

txt_ClientCode = "AA3"

If len(txt_ClientCode)>0 Then

'strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
Where ClientCode='" & txt_ClientCode & "'"

strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
Where ClientCode = '" & txt_ClientCode & "'"

Set oRS = Server.CreateObject("ADODB.RecordSet")

oRS.Open strSQL,Application("ConnectionString"),adOpenKeyset,adLockOptimistic

If Not (oRS.EOF And oRS.BOF) Then

strtext = oRS("ClientCode")
Response.Write(strtext)
oRS.Delete
oRS.Update

End IF
oRS.Close
Set oRS = Nothing
Response.End
End If

%>

*****************************************************************************
******************VBSCRIPT CODE********************************
*****************************************************************************

</BODY>
</HTML>

Re: ASP Pages accessing databse issue by Jan

Jan
Wed Jan 05 07:46:53 CST 2005

Remove the = thats in front of the variable

"Colin Graham" <csgraham74@hotmail.com> schreef in bericht
news:ee261922.0501050445.4551d7b1@posting.google.com...
>I am attempting to retrieve a value from a database and populate a
> textbox on my html form. This code appears to run fine without error
> but i do not get any value in my textbox. Im very new to ASP and im
> having to change an existing system. If i do not put my vbscript code
> at the bottom of the screen then my page will not render correctly.
> Can anyone please help me ??? Are there any major flaws with my code
> ??? should my script be before my textbox ???? by the way im only
> hardcoding input values for test purposes.
>
> <%@ Language=vbscript LCID=2057%>
> <HTML>
> <HEAD>
> <title>IDD Document</title>
> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
> </HEAD>
> <body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
> MS_POSITIONING="GridLayout" bgcolor="#ffdcff">
>
>
> <form id="Form1" method="post" runat="server">
> <TABLE id="Table1" style="Z-INDEX: 102; LEFT: 0px; POSITION: absolute;
> TOP: 0px" cellSpacing="0"cellPadding="0" width="100%" border="0"
> height="100%">
> <TBODY>
> <TR>
> <TD style="HEIGHT: 42px" vAlign="top">
> <BR>
> <INPUT id="btn_BackToMenu" type="button" value="Close Window"
> onclick="window.close()" runat="server"></TD>
>
> *******************************************************************
> *******************TEXT BOX I WANT TO POPULATE*********************
>
> <input type="text" name="T1" size="20" value="<%= strtext%>"
>
> *******************************************************************
> *******************************************************************
>
> </TR>
> <TR>
>
> <TD><iframe name="myIframe" height="100%" width="100%"
> frameborder=no src="documents/IDD.pdf" </TR>
> </td></form>
>
> </TABLE>
> </form>
> </body></IFRAME></TR></TBODY></TABLE></FORM>
> *****************************************************************************
> ******************VBSCRIPT CODE********************************
> *****************************************************************************
> <%
>
> Dim oRS, strSQL, txt_ClientCode, strtext
>
> txt_ClientCode = "AA3"
>
> If len(txt_ClientCode)>0 Then
>
> 'strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
> Where ClientCode='" & txt_ClientCode & "'"
>
> strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
> Where ClientCode = '" & txt_ClientCode & "'"
>
> Set oRS = Server.CreateObject("ADODB.RecordSet")
>
> oRS.Open
> strSQL,Application("ConnectionString"),adOpenKeyset,adLockOptimistic
>
> If Not (oRS.EOF And oRS.BOF) Then
>
> strtext = oRS("ClientCode")
> Response.Write(strtext)
> oRS.Delete
> oRS.Update
>
> End IF
> oRS.Close
> Set oRS = Nothing
> Response.End
> End If
>
> %>
>
> *****************************************************************************
> ******************VBSCRIPT CODE********************************
> *****************************************************************************
>
> </BODY>
> </HTML>



Re: ASP Pages accessing databse issue by Bob

Bob
Wed Jan 05 08:21:29 CST 2005

Why?
Jan wrote:
> Remove the = thats in front of the variable
>
> "Colin Graham" <csgraham74@hotmail.com> schreef in bericht
> news:ee261922.0501050445.4551d7b1@posting.google.com...
>> I am attempting to retrieve a value from a database and populate a
>> textbox on my html form. This code appears to run fine without error
>> but i do not get any value in my textbox. Im very new to ASP and im
>> having to change an existing system. If i do not put my vbscript code
>> at the bottom of the screen then my page will not render correctly.
>> Can anyone please help me ??? Are there any major flaws with my code
>> ??? should my script be before my textbox ???? by the way im only
>> hardcoding input values for test purposes.
>>
>> <%@ Language=vbscript LCID=2057%>
>> <HTML>
>> <HEAD>
>> <title>IDD Document</title>
>> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
>> </HEAD>
>> <body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
>> MS_POSITIONING="GridLayout" bgcolor="#ffdcff">
>>
>>
>> <form id="Form1" method="post" runat="server">
>> <TABLE id="Table1" style="Z-INDEX: 102; LEFT: 0px; POSITION:
>> absolute; TOP: 0px" cellSpacing="0"cellPadding="0" width="100%"
>> border="0" height="100%">
>> <TBODY>
>> <TR>
>> <TD style="HEIGHT: 42px" vAlign="top">
>> <BR>
>> <INPUT id="btn_BackToMenu" type="button" value="Close Window"
>> onclick="window.close()" runat="server"></TD>
>>
>> *******************************************************************
>> *******************TEXT BOX I WANT TO POPULATE*********************
>>
>> <input type="text" name="T1" size="20" value="<%= strtext%>"
>>
>> *******************************************************************
>> *******************************************************************
>>
>> </TR>
>> <TR>
>>
>> <TD><iframe name="myIframe" height="100%" width="100%"
>> frameborder=no src="documents/IDD.pdf" </TR>
>> </td></form>
>>
>> </TABLE>
>> </form>
>> </body></IFRAME></TR></TBODY></TABLE></FORM>
>>
****************************************************************************
*
>> ******************VBSCRIPT CODE********************************
>>
****************************************************************************
*
>> <%
>>
>> Dim oRS, strSQL, txt_ClientCode, strtext
>>
>> txt_ClientCode = "AA3"
>>
>> If len(txt_ClientCode)>0 Then
>>
>> 'strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
>> Where ClientCode='" & txt_ClientCode & "'"
>>
>> strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
>> Where ClientCode = '" & txt_ClientCode & "'"
>>
>> Set oRS = Server.CreateObject("ADODB.RecordSet")
>>
>> oRS.Open
>> strSQL,Application("ConnectionString"),adOpenKeyset,adLockOptimistic
>>
>> If Not (oRS.EOF And oRS.BOF) Then
>>
>> strtext = oRS("ClientCode")
>> Response.Write(strtext)
>> oRS.Delete
>> oRS.Update
>>
>> End IF
>> oRS.Close
>> Set oRS = Nothing
>> Response.End
>> End If
>>
>> %>
>>
>>
****************************************************************************
*
>> ******************VBSCRIPT CODE********************************
>>
****************************************************************************
*
>>
>> </BODY>
>> </HTML>

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: ASP Pages accessing databse issue by Ray

Ray
Wed Jan 05 08:29:49 CST 2005

You're trying to write the value of strText before the code that
gives it a value is executed. The code in your page is executed in
the order it appears. This illustrates:

<html><body>
<% Dim strText %>
The value of strText is <%=strText%><br>
<% strText = "Colin" %>
The value of strText, now, is <%=strText%>
</body></html>

Consider encapsulating your code in subs or functions as much as
possible. If you put all the code into a function (minus the
response.end), you could leave it where you have it if that is your
preference. This illustrates:

<html><body>
The value of the function is <%=theFunction()%><br>
</body></html>
<%
Function theFunction()
''code, code, code
theFunction = "Here's a value."
End Function
%>


--

Ray at work
Microsoft ASP/ASP.NET MVP


"Colin Graham" <csgraham74@hotmail.com> wrote in message
news:ee261922.0501050445.4551d7b1@posting.google.com...
> I am attempting to retrieve a value from a database and populate a
> textbox on my html form. This code appears to run fine without
error
> but i do not get any value in my textbox. Im very new to ASP and im
> having to change an existing system. If i do not put my vbscript
code
> at the bottom of the screen then my page will not render correctly.
> Can anyone please help me ??? Are there any major flaws with my
code
> ??? should my script be before my textbox ???? by the way im only
> hardcoding input values for test purposes.
>
> <%@ Language=vbscript LCID=2057%>
> <HTML>
> <HEAD>
> <title>IDD Document</title>
> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
> </HEAD>
> <body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
> MS_POSITIONING="GridLayout" bgcolor="#ffdcff">
>
>
> <form id="Form1" method="post" runat="server">
> <TABLE id="Table1" style="Z-INDEX: 102; LEFT: 0px; POSITION:
absolute;
> TOP: 0px" cellSpacing="0"cellPadding="0" width="100%" border="0"
> height="100%">
> <TBODY>
> <TR>
> <TD style="HEIGHT: 42px" vAlign="top">
> <BR>
> <INPUT id="btn_BackToMenu" type="button" value="Close Window"
> onclick="window.close()" runat="server"></TD>
>
> *******************************************************************
> *******************TEXT BOX I WANT TO POPULATE*********************
>
> <input type="text" name="T1" size="20" value="<%= strtext%>"
>
> *******************************************************************
> *******************************************************************
>
> </TR>
> <TR>
>
> <TD><iframe name="myIframe" height="100%" width="100%"
> frameborder=no src="documents/IDD.pdf" </TR>
> </td></form>
>
> </TABLE>
> </form>
> </body></IFRAME></TR></TBODY></TABLE></FORM>
>
*********************************************************************
********
> ******************VBSCRIPT CODE********************************
>
*********************************************************************
********
> <%
>
> Dim oRS, strSQL, txt_ClientCode, strtext
>
> txt_ClientCode = "AA3"
>
> If len(txt_ClientCode)>0 Then
>
> 'strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
> Where ClientCode='" & txt_ClientCode & "'"
>
> strSQL = "Select ClientCode, PDFName From tbl_PaymentProtectionPDF
> Where ClientCode = '" & txt_ClientCode & "'"
>
> Set oRS = Server.CreateObject("ADODB.RecordSet")
>
> oRS.Open
strSQL,Application("ConnectionString"),adOpenKeyset,adLockOptimistic
>
> If Not (oRS.EOF And oRS.BOF) Then
>
> strtext = oRS("ClientCode")
> Response.Write(strtext)
> oRS.Delete
> oRS.Update
>
> End IF
> oRS.Close
> Set oRS = Nothing
> Response.End
> End If
>
> %>
>
>
*********************************************************************
********
> ******************VBSCRIPT CODE********************************
>
*********************************************************************
********
>
> </BODY>
> </HTML>