2016-05-08 10 views
0

サイト全体がクラッシュしています。待機操作がタイムアウトしている、私は{}ブロックを使用してドキュメントを読んだが、なぜこれが起こっているのか理解できません。どんな助けもありがとうございます。ASP.NET C#待機操作がタイムアウトしました

[Win32Exception (0x80004005): The wait operation timed out] 

私が最も最近に取り組んできているページは itemediting.aspxです:背後に

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="itemediting.aspx.cs" Inherits="admin_itemediting" %> 

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>elmtree - Admin</title>  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 

<!-- Latest compiled and minified CSS --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> 

<!-- Optional theme --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" /> 

<!-- Latest compiled and minified JavaScript --> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
<link rel="stylesheet" href="../styles/mylist.css" /> 

</head> 
<body> 
    <form id="form1" runat="server"> 

     <img src="images/ELleft.png" style="width:226px; height:52px; margin-top: 3px; margin-left: 17px; text-align: justify; float: none;"/></a></li> 

<div class="container"> 
    <h1> Item Edit </h1> </div>  
     <div class="container">  
      <div class="form-group">  
       <label class="col-sm-2 control-label">Item name: </label>  
       <div class="col-md-4"> 
        <asp:TextBox ID="itemnametext" runat="server" Text="" CssClass="form-control">  
        </asp:TextBox> 
       </div> 
       <div class="pull-right"> 
        <asp:Button CssClass="btn btn-primary btn-lg" ID="updatebutton" role="button" runat="server" Text="save" OnClick="updatebutton_Click" /> 
       </div> 
      </div>  
     </div>    
     </form> 
    </body> 
    </html> 

コード:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI.WebControls;  
using System.IO; 
using System.Data; 
using System.Data.SqlClient; 
using System.Web.Configuration;  

public partial class admin_itemediting : System.Web.UI.Page{ 

    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 
      int row = 0; 
      if (Request.QueryString["itemID"] != null) 
      {  
       row = int.Parse(Request.QueryString["itemID"]); 
      } 
      else 
      { 
       Response.Redirect("itemedit.aspx"); 
      }  
     } 

     string connectionString = WebConfigurationManager.ConnectionStrings 
      ["ConnectionString"].ConnectionString; 

     SqlConnection myConnection = new SqlConnection(connectionString);  
     myConnection.Open();  
     string query = "SELECT * FROM reports WHERE [email protected]";   
     SqlCommand myCommand = new SqlCommand(query, myConnection);  
     myCommand.Parameters.AddWithValue("@rowid", row);  
     SqlDataReader rdr = myCommand.ExecuteReader(); 

     while (rdr.Read()) 
     { 
      string myname = rdr["itemname"].ToString();  
      itemnametext.Text = myname; 
     } 
    } 

    protected void updatebutton_Click(object sender, EventArgs e){ 

     string connectionString = WebConfigurationManager.ConnectionStrings ["ConnectionString"].ConnectionString;  
     SqlConnection myConnection = new SqlConnection(connectionString);  
     myConnection.Open();  
     string itemnametextupdate = itemnametext.Text;  
     string query = "UPDATE reports SET itemname = @itemnewname";   
     SqlCommand myCommand = new SqlCommand(query, myConnection);  
     myCommand.Parameters.AddWithValue("@itemnewname", itemnametextupdate);  
     myCommand.ExecuteNonQuery();  
     myConnection.Close();  
     Response.Redirect("updateimage.aspx");  
    } 

    public object row { get; set; } 
} 
+1

どのステートメントでタイムアウトしましたか? –

+0

正直なところ私は考えていない、私は更新機能を追加しようとするまで、サイトは正常に動作していた。 myCommand.Parameters.AddWithValue( "@ rowid"、row)の 'row'が表示されています。エラーが発生しています。 – Cmc9

+0

'myCommand.Parameters.AddWithValue(" @ rowid "、row);'にブレークポイントを設定し、その行に値があることを確認します。 'Debug.WriteLine(row);; –

答えて

0

だけの提案。

if (!IsPostBack) 
     { 
      int row = 0; 
      if (Request.QueryString["itemID"] != null) 
      {  
       row = int.Parse(Request.QueryString["itemID"]); 
      } 
      else 
      { 
       // here even if you make redirect the code continue to run 
       // and you do not know whats going on then... a call to db and a redirect. 
       Response.Redirect("itemedit.aspx"); 
       // so here add a return; 
       return; 
      }  
     } 

次の可能なバグがポストに戻ってrowはないビューステートに保存され、デフォルト値を取ることです。 row変数を次のように変更してください:

int cRow 
{ 
    set 
    { 
     ViewState["cRow"] = value; 
    } 
    get 
    { 
     if (ViewState["cRow"] != null) 
      return Convert.ToInt32(ViewState["cRow"]); 
     else 
      return -1; 
    } 
} 
関連する問題