S
Sean
Hi There,
I am making the trasition from asp to asp .net, I have a page below which
has 3 user controls on it. The 3rd usercontrol (<UserControl3:terms
runat="server" />) calls a stored procedure to return one row to display on
a page, everything works fine except no matter what I do the function is
called first with the Sub Page_Load and the results end up in the top
lefthand corner.
What I want to know is how I can access the db without having the code in a
sub routine? I have tried to remove the sub calls but then I get an error
saying "myConnection " is not defined. Could someone help me out with some
code?
Sean - thanks in advance
!--- usercontrol page
<%@ Control Language="vb" EnableViewState="False" %>
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
Dim drRead As SqlDataReader
Dim strTermsConditions as String
Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
myConnection.Open()
Dim myCommand As New SqlCommand("GetListingStates", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
drRead = myCommand.ExecuteReader()
While drRead.Read ( )
strTermsConditions = drRead(0)
End While
</script>
!-- aspx page
<%@ Register TagPrefix="UserControl1" TagName="Menu"
Src="includes/_Menu.ascx" %>
<%@ Register TagPrefix="UserControl2" TagName="Header"
Src="includes/_Header.ascx" %>
<%@ Register TagPrefix="UserControl3" TagName="terms"
Src="includes/_terms_content.ascx" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="distribution" content="global">
<meta name="revisit-after" content="14 days">
<meta name="ROBOTS" content="ALL">
<title>title</title>
</head>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<table width="640" border="0" cellpadding="0" cellspacing="0">
<td colspan="2" valign=top><UserControl2:Header runat="server" /></td>
<tr>
<td width="100" valign=top><UserControl1:Menu runat="server" /></td>
<td width="563" valign=top><UserControl3:terms runat="server" /></td>
</tr>
<TR>
<td colspan=2> footer</td>
<td>
</tr>
</table>
</body>
</html>
I am making the trasition from asp to asp .net, I have a page below which
has 3 user controls on it. The 3rd usercontrol (<UserControl3:terms
runat="server" />) calls a stored procedure to return one row to display on
a page, everything works fine except no matter what I do the function is
called first with the Sub Page_Load and the results end up in the top
lefthand corner.
What I want to know is how I can access the db without having the code in a
sub routine? I have tried to remove the sub calls but then I get an error
saying "myConnection " is not defined. Could someone help me out with some
code?
Sean - thanks in advance
!--- usercontrol page
<%@ Control Language="vb" EnableViewState="False" %>
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
Dim drRead As SqlDataReader
Dim strTermsConditions as String
Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
myConnection.Open()
Dim myCommand As New SqlCommand("GetListingStates", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
drRead = myCommand.ExecuteReader()
While drRead.Read ( )
strTermsConditions = drRead(0)
End While
</script>
!-- aspx page
<%@ Register TagPrefix="UserControl1" TagName="Menu"
Src="includes/_Menu.ascx" %>
<%@ Register TagPrefix="UserControl2" TagName="Header"
Src="includes/_Header.ascx" %>
<%@ Register TagPrefix="UserControl3" TagName="terms"
Src="includes/_terms_content.ascx" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="distribution" content="global">
<meta name="revisit-after" content="14 days">
<meta name="ROBOTS" content="ALL">
<title>title</title>
</head>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<table width="640" border="0" cellpadding="0" cellspacing="0">
<td colspan="2" valign=top><UserControl2:Header runat="server" /></td>
<tr>
<td width="100" valign=top><UserControl1:Menu runat="server" /></td>
<td width="563" valign=top><UserControl3:terms runat="server" /></td>
</tr>
<TR>
<td colspan=2> footer</td>
<td>
</tr>
</table>
</body>
</html>