
June 16th, 2004, 08:47 AM
|
|
Contributing User
|
|
Join Date: Jun 2004
Posts: 43
Time spent in forums: < 1 sec
Reputation Power: 4
|
|
|
Help! Why does my page take so long submit!
Hello all. I am looking for help discovering why my form page takes so long to load (roughly a minute). Operationaly, it works great, performing all the tasks I ask it to. The actual page loads fine. However, when the submit button is clicked to enter the data into the database, it takes roughly a minute to process and perform this request. Here is my entire code. Are there any red flags here that are evidently making this page load so slowly? I would appreciate any help!
Code:
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SQLClient" %>
<script runat="server">
Dim connstr as string = "Server=localhost;UID=User;PWD=PW;Database=Database"
Dim return_page as string = "transfers.aspx"
Dim cancel_page as string = "bscireal.aspx"
Sub Page_Load(sender As Object, e As EventArgs)
Dim rightNow as DateTime = DateTime.Now
If day(RightNow) > 25 Then
lbl_error.text = "You are not able to transfer accounts after the 25th of the month.
Please try again next month."
else
lbl_error.text = "Welcome to the Account Transfers Page. Please select an account and the
territory you wish to transfer to."
Dim sql as string
if not Page.IsPostBack then
sql = "select AccountID + ' - ' + AccountName as accnumber from Accounts order by
AccountName"
FillDropDownList(sql,AccNumber)
end if
if not Page.IsPostBack then
sql = "select distinct territoryName from Territories"
FillDropDownList(sql,Toname)
end if
end if
End Sub
Sub FillDropDownList(sql as string, ddl as DropDownList)
' Create Connection Object, Command Object, Connect to the database
Dim conn as New SQLConnection(connstr)
Dim cmd as New SQLCommand(sql,conn)
conn.open()
' Execute the SQL, Bind the results to the Dropdown List Control
ddl.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
ddl.DataBind()
End Sub
Sub InsertData()
Dim conn as SQLConnection
Conn = New SQLConnection(connstr)
Dim Cmd1 as SqlCommand
Cmd1 = New SQLCommand("Insertaccounts",Conn)
'Declare the command type - a stored proc in this case
Cmd1.commandType = CommandType.storedProcedure
'Add the parameters
Cmd1.parameters.add("@AccountID",AccNumber.SelectedItem.Value)
dim cmd2 as SqlCommand
Cmd2 = New SQLCommand("UpdateToTerritory",Conn)
'Declare the command type - a stored proc in this case
Cmd2.commandType = CommandType.storedProcedure
Cmd2.parameters.add("@AccountID",AccNumber.SelectedItem.Value)
Cmd2.parameters.add("@ToName",ToName.SelectedItem.Value)
conn.open()
cmd1.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
conn.Close()
Response.redirect(return_page)
end sub
Sub cmdInsert_Click(sender As Object, e As EventArgs)
InsertData()
End Sub
Sub cmdCancel_Click(sender As Object, e As EventArgs)
response.redirect(cancel_page)
End Sub
</script>
<html>
<head>
<title>Account Transfers</title>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>
<body class="empty" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<form onsubmit="return Validate(this)" action="transfers.aspx?Enter=True" method="POST"
runat="server" name="form1">
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr bgcolor="#000000">
<td valign="top" align="left">
</td>
</tr>
<tr>
<td width="100%" background="gor_white.bmp">
<img height="1" src="images/gor_white.gif" width="20" border="NONE" /></td>
</tr>
<tr bgcolor="#002041">
<td valign="top" align="left" width="100%" height="77">
<img height="77" src="images/header.bmp" width="960" /></td>
</tr>
<tr>
<td width="100%" background="gor_white.bmp">
<img height="1" src="images/gor_white.bmp" width="20" border="NONE" /></td>
</tr>
<tr bgcolor="#36647e">
<td valign="top" align="left">
</td>
</tr>
<tr>
<td valign="center" align="middle" height="98%">
<table bordercolor="#5e768e" cellspacing="0" cellpadding="5" width="80%"
bgcolor="#b6cce4" border="1">
<tbody>
<tr><td colspan="2" align="center" valign="middle"><asp:Label id="lbl_error"
runat="server" width="500px" font="verdana" forecolor="#5e768e"></asp:Label></center></td></tr>
<td width="400" border="0" valign="top"><br />
<font face="Verdana" size="2"><b>Account Number: </b></font><br />
<asp:DropDownList id="AccNumber" name="AccNumber" runat="server"
DataValueField="accnumber" DataTextField="AccNumber" Width="400px"></asp:DropDownList>
<br /><br />
<font face="Verdana" size="2"><b>Transer to:</b></font><br />
<asp:DropDownList id="ToName" name="ToName" runat="server"
DataValueField="TerritoryName" DataTextField="TerritoryName" Width="215px"></asp:DropDownList><br /><br
/><br />
<center>
<asp:Button id="cmdInsert" onclick="cmdInsert_Click"
runat="server" Text="Insert Record" type="submit"></asp:Button>
<asp:Button id="cmdCancel" onclick="cmdCancel_Click"
runat="server" Text="Cancel"></asp:Button>
</center>
</td><td>
<CENTER><IMG SRC="images/login.bmp" width="360" height="270"
border="0" valign="middle"></CENTER></td>
</tr>
</tbody>
</table>
</td>
</tr>
</form>
<td valign="top" align="middle">
</td></tr>
<tr>
<td valign="top" align="middle" colspan="3">
<hr color="#5e768e" />
</td>
</tr>
<tr>
<td valign="top" align="middle" colspan="3" bgcolor="#002041">
<font class="text_bold_bl" color="#FFFFFF" face="verdana" size="1">The contents of this site
are highly confidential </font></td>
</tr>
<tr>
<td align="CENTER" valign="TOP" bgcolor="#002041">
<font class="copyright"><font class="copyright_lnk" color="#FFFFFF" face="verdana"
size="1">Copyright 2000. </font></td>
</tr>
</tbody>
</table>
</body>
</html>
|