Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Strange problem :( 2 clicks b4 it works!
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Strange problem :( 2 clicks b4 it works!

 Post Reply Post Reply Page  12>
Author
MrCarl View Drop Down
Newbie
Newbie


Joined: 29 March 2003
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrCarl Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 February 2004 at 5:49pm

Originally posted by Diep-Vriezer 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.

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 13 February 2004 at 6:41pm
Gone..
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 15 February 2004 at 10:15pm
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.