在前面加上:
sqlCommand = new SqlCommand();

解决方案 »

  1.   

    這是省略的部分:
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace Reponline
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class frmReponline : System.Windows.Forms.Form
    {
    private System.Windows.Forms.GroupBox groLogin;
    private System.Windows.Forms.TextBox texPassword;
    private System.Windows.Forms.Label labPassword;
    private System.Windows.Forms.TextBox texNtaccount;
    private System.Windows.Forms.Label labNtaccount;
    private System.Windows.Forms.Button butOK;
    private System.Windows.Forms.Button butExit;
    private System.Windows.Forms.PictureBox picLogo;
    private System.Data.SqlClient.SqlConnection sqlConnection;
    private System.Data.SqlClient.SqlCommand sqlCommand;
    private System.Data.SqlClient.SqlDataReader sqlDataReader;
    private string strNtaccount;
    private string strRight;
    private string strOrg;
    private string strOwner;
    private string strEmpcode;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null; public frmReponline()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmReponline));
    this.groLogin = new System.Windows.Forms.GroupBox();
    this.picLogo = new System.Windows.Forms.PictureBox();
    this.butExit = new System.Windows.Forms.Button();
    this.butOK = new System.Windows.Forms.Button();
    this.texPassword = new System.Windows.Forms.TextBox();
    this.labPassword = new System.Windows.Forms.Label();
    this.texNtaccount = new System.Windows.Forms.TextBox();
    this.labNtaccount = new System.Windows.Forms.Label();
    this.sqlConnection = new System.Data.SqlClient.SqlConnection();
    this.sqlCommand = new System.Data.SqlClient.SqlCommand();
    this.groLogin.SuspendLayout();
    this.SuspendLayout();
    // 
    // groLogin
    // 
    this.groLogin.Controls.AddRange(new System.Windows.Forms.Control[] {
       this.picLogo,
       this.butExit,
       this.butOK,
       this.texPassword,
       this.labPassword,
       this.texNtaccount,
       this.labNtaccount});
    this.groLogin.Location = new System.Drawing.Point(3, 1);
    this.groLogin.Name = "groLogin";
    this.groLogin.Size = new System.Drawing.Size(192, 156);
    this.groLogin.TabIndex = 4;
    this.groLogin.TabStop = false;
    // 
    // picLogo
    // 
    this.picLogo.Image = ((System.Drawing.Bitmap)(resources.GetObject("picLogo.Image")));
    this.picLogo.Location = new System.Drawing.Point(8, 88);
    this.picLogo.Name = "picLogo";
    this.picLogo.Size = new System.Drawing.Size(56, 64);
    this.picLogo.TabIndex = 10;
    this.picLogo.TabStop = false;
    // 
    // butExit
    // 
    this.butExit.Location = new System.Drawing.Point(144, 120);
    this.butExit.Name = "butExit";
    this.butExit.Size = new System.Drawing.Size(40, 24);
    this.butExit.TabIndex = 9;
    this.butExit.Text = "退出";
    this.butExit.Click += new System.EventHandler(this.butExit_Click);
    // 
    // butOK
    // 
    this.butOK.Location = new System.Drawing.Point(96, 120);
    this.butOK.Name = "butOK";
    this.butOK.Size = new System.Drawing.Size(40, 24);
    this.butOK.TabIndex = 8;
    this.butOK.Text = "確定";
    this.butOK.Click += new System.EventHandler(this.butOK_Click);
    // 
    // texPassword
    // 
    this.texPassword.Location = new System.Drawing.Point(112, 66);
    this.texPassword.Name = "texPassword";
    this.texPassword.PasswordChar = '*';
    this.texPassword.Size = new System.Drawing.Size(58, 22);
    this.texPassword.TabIndex = 7;
    this.texPassword.Text = "";
    // 
    // labPassword
    // 
    this.labPassword.Location = new System.Drawing.Point(56, 71);
    this.labPassword.Name = "labPassword";
    this.labPassword.Size = new System.Drawing.Size(51, 16);
    this.labPassword.TabIndex = 6;
    this.labPassword.Text = "密    碼";
    this.labPassword.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    // 
    // texNtaccount
    // 
    this.texNtaccount.Location = new System.Drawing.Point(83, 23);
    this.texNtaccount.Name = "texNtaccount";
    this.texNtaccount.Size = new System.Drawing.Size(61, 22);
    this.texNtaccount.TabIndex = 5;
    this.texNtaccount.Text = "";
    // 
    // labNtaccount
    // 
    this.labNtaccount.Location = new System.Drawing.Point(32, 28);
    this.labNtaccount.Name = "labNtaccount";
    this.labNtaccount.Size = new System.Drawing.Size(45, 16);
    this.labNtaccount.TabIndex = 4;
    this.labNtaccount.Text = "帳   號";
    this.labNtaccount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    // 
    // sqlConnection
    // 
    this.sqlConnection.ConnectionString = "data source=WJDBOA02S;initial catalog=WJWWWDB;password=oauser;persist security in" +
    "fo=True;user id=oauser";
    // 
    // frmReponline
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
    this.BackColor = System.Drawing.SystemColors.ActiveBorder;
    this.ClientSize = new System.Drawing.Size(200, 165);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.groLogin});
    this.ForeColor = System.Drawing.SystemColors.Desktop;
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
    this.MaximizeBox = false;
    this.MinimizeBox = false;
    this.Name = "frmReponline";
    this.Text = "線上報修管理系統";
    this.Load += new System.EventHandler(this.frmReponline_Load);
    this.groLogin.ResumeLayout(false);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
      

  2.   

    這一句:
    this.sqlCommand = new System.Data.SqlClient.SqlCommand();
    就是sqlCommand=new sqlCommand()的意思呀
      

  3.   

    第二次的时候必须保证以下值为空!         
    strNtaccount="";
    strOrg="";
    strEmpcode="";
    strOwner= "";
    strRight="";