測試過沒問題.
如果你開始把ojbect1="";就不行了注意""!=null
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
namespace Debug
{
/// <summary>
/// WebForm1 的摘要描述。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlConnection sqlConn;
protected System.Web.UI.WebControls.Button Button1;
protected System.Data.SqlClient.SqlCommand sqlComm;
protected string s;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 此呼叫為 ASP.NET Web Form 設計工具的必要項。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 此為設計工具支援所必需的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.sqlConn = new System.Data.SqlClient.SqlConnection();
this.sqlComm = new System.Data.SqlClient.SqlCommand();
//
// sqlComm
//
this.sqlComm.Connection = this.sqlConn;
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);