| Author |
Topic Search Topic Options
|
MrCarl
Newbie
Joined: 29 March 2003
Status: Offline
Points: 29
|
Post Options
Thanks(0)
Quote Reply
Topic: Strange problem :( 2 clicks b4 it works! Posted: 13 February 2004 at 12:34pm |
Hi,
I have setup a form which has a search textbox which you can either leave blank to search for all, or enter a number for it to query the database with.
It all seems to work fine, except if I put a number into the textbox I and click the submit button it doesnt query the database correctly and stays the same, but if I click it a second time it works!! really strange... Please helpn and let me know where im going wrong!!
Here is the code...
Thanks
- Carl
<%@ Page Language="VB" Debug="true" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.SqlClient" %> <script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
End Sub Sub subPurchaseOrderSearch(sender As Object, e As ImageClickEventArgs)
Dim conSql as New SqlConnection(ConfigurationSettings.AppSettings("strCon")) Dim strSql as String = "SELECT tblPurchaseOrders.intPoNumber, tblPurchaseOrders.datRaised, tblPurchaseOrders.decAmount, tblPurchaseOrders.strStatus " _ & "FROM tblPurchaseOrders " Dim sbSqlWhere as StringBuilder = New StringBuilder()
If Not frmOrderNo.Text = "" Then sbSqlWhere.Append("WHERE tblPurchaseOrders.intPoNumber = " & frmOrderNo.Text) Dim comSql as New SqlCommand(strSql & sbSqlWhere.ToString(), conSql)
conSql.Open() dgPurchaseOrderList.DataSource = comSql.ExecuteReader(CommandBehavior.CloseConnection) dgPurchaseOrderList.DataBind() conSql.Close() End Sub Sub subPurchaseOrderView(sender as Object, e As DataGridCommandEventArgs) Dim idJobVacancy as Integer = Convert.ToInt32(e.Item.Cells(0).text) Response.Redirect("PurchaseOrderView.aspx?id=" & idJobVacancy) End Sub
</script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Westmead - Driven by the Future</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="/sty/MainStyle.css" type="text/css" rel="stylesheet"> <script language="javascript" src="/inc/incFormFunctions.js"></script> </head> <body> <form enctype="multipart/form-data" runat="server"> <asp:TextBox id="frmOrderNo" tabIndex="2" runat="server" CssClass="form" AutoPostBack="true" MaxLength="10" TextMode="SingleLine" /> <asp:ImageButton AlternateText="Click here to search for vacancy" id="ImageButton" ImageUrl="gfx/button_search.gif" runat="server" tabIndex="6" OnClick="subPurchaseOrderSearch" /> <br> <asp:datagrid id="dgPurchaseOrderList" runat="server" CssClass="tableStyle1" AutoGenerateColumns="false" BorderColor="#000000" BorderStyle="Solid" CellPadding="5" CellSpacing="0" Width="100%" OnItemCommand="subPurchaseOrderView"> <HeaderStyle cssclass="bold" /> <AlternatingItemStyle cssclass="tableRow2" /> <ItemStyle cssclass="tableRow1" /> <Columns> <asp:BoundColumn DataField="intPoNumber" HeaderText="P/O Number" /> <asp:BoundColumn DataField="datRaised" HeaderText="Date" /> <asp:BoundColumn DataField="decAmount" HeaderText="Value" /> <asp:BoundColumn DataField="strStatus" HeaderText="Status" /> <asp:ButtonColumn Text="View" HeaderText="View" /> </Columns> </asp:datagrid> </form> </body> </html>
|
|
 |
Diep-Vriezer
Senior Member
Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
|
Post Options
Thanks(0)
Quote Reply
Posted: 13 February 2004 at 4:12pm |
|
Looks like you're temp. inet files are filled or something. Try displaying the results on another page, and it won't happen again. How to solve it.. Hmm. Try deleting your temp inet files, then rebuild (or rerun) the application and see.
|
|
Gone..
|
 |
Diep-Vriezer
Senior Member
Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
|
Post Options
Thanks(0)
Quote Reply
Posted: 13 February 2004 at 4:14pm |
|
Btw, the conSQL.Close() isn't needed, since you're closing the connection using Commandbehavior.CloseConnection right?
|
|
Gone..
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 13 February 2004 at 4:26pm |
|
I had a similar problem once, can't think off hand how I solved it... I will get back to you if I remember.
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 13 February 2004 at 5:49pm |
Diep-Vriezer wrote:
Btw, the conSQL.Close() isn't needed, since you're closing the connection using Commandbehavior.CloseConnection right? |
Actually the opposite, with commandbehaviour.closeconnection you explicity tell the page that you will close the connection.
|
|
|
 |
Diep-Vriezer
Senior Member
Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
|
Post Options
Thanks(0)
Quote Reply
Posted: 13 February 2004 at 6:41pm |
|
|
|
Gone..
|
 |
Bunce
Senior Member
Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
|
Post Options
Thanks(0)
Quote Reply
Posted: 15 February 2004 at 9:51pm |
That option will close the connection when you close the reader.
|
|
There have been many, many posts made throughout the world...
This was one of them.
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 15 February 2004 at 10:15pm |
|
|
|
|
 |