try
this.sqlDataAdapter1.Fill(this.dataSet11,"Customers");

解决方案 »

  1.   

    问题可能不在这个地方
    你try catch
    然后贴出异常的详细信息
      

  2.   

    或者尝试
    this.sqlDataAdapter1.Fill(this.dataSet11,0,1,"Customers");
      

  3.   

    一般都用
    this.sqlDataAdapter1.Fill(this.dataSet11,"Customers");
    你的dataSet11的数据没问题吧?
      

  4.   

    就一个 fill能看出 什么来呀
      

  5.   



    private void InitializeComponent()
    {
    this.txtCustID = new System.Windows.Forms.TextBox();
    this.label1 = new System.Windows.Forms.Label();
    this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.dataSet11 = new ch18ex01.DataSet1();
    this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
    this.button1 = new System.Windows.Forms.Button();
    ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
    this.SuspendLayout();
    // 
    // txtCustID
    // 
    this.txtCustID.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "Customers.CustomerID"));
    this.txtCustID.Location = new System.Drawing.Point(48, 144);
    this.txtCustID.Name = "txtCustID";
    this.txtCustID.Size = new System.Drawing.Size(160, 21);
    this.txtCustID.TabIndex = 0;
    this.txtCustID.Text = "";
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(48, 80);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(144, 16);
    this.label1.TabIndex = 1;
    this.label1.Text = "客户ID";
    // 
    // sqlDataAdapter1
    // 
    this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
    this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
    this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
    this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
     new System.Data.Common.DataTableMapping("Table", "Customers", new System.Data.Common.DataColumnMapping[] {
    new System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"),
    new System.Data.Common.DataColumnMapping("ContactName", "ContactName"),
     new System.Data.Common.DataColumnMapping("CustomerID", "CustomerID")})});
    this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
    this.sqlDataAdapter1.RowUpdated += new System.Data.SqlClient.SqlRowUpdatedEventHandler(this.sqlDataAdapter1_RowUpdated);
    // 
    // sqlConnection1
    // 
    this.sqlConnection1.ConnectionString = "workstation id=BEYOND;packet size=4096;user id=sa;data source=BEYOND;persist secu" +
    "rity info=False;initial catalog=Northwind";
    // 
    // dataSet11
    // 
    this.dataSet11.DataSetName = "DataSet1";
    this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
    // 
    // sqlSelectCommand1
    // 
    this.sqlSelectCommand1.CommandText = "SELECT CompanyName, ContactName, CustomerID FROM Customers";
    this.sqlSelectCommand1.Connection = this.sqlConnection1;
    // 
    // sqlInsertCommand1
    // 
    this.sqlInsertCommand1.CommandText = "INSERT INTO Customers(CompanyName, ContactName, CustomerID) VALUES (@CompanyName," +
    " @ContactName, @CustomerID); SELECT CompanyName, ContactName, CustomerID FROM Cu" +
    "stomers WHERE (CustomerID = @CustomerID)";
    this.sqlInsertCommand1.Connection = this.sqlConnection1;
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CompanyName", System.Data.SqlDbType.NVarChar, 40, "CompanyName"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ContactName", System.Data.SqlDbType.NVarChar, 30, "ContactName"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CustomerID", System.Data.SqlDbType.NVarChar, 5, "CustomerID"));
    // 
    // sqlUpdateCommand1
    // 
    this.sqlUpdateCommand1.CommandText = @"UPDATE Customers SET CompanyName = @CompanyName, ContactName = @ContactName, CustomerID = @CustomerID WHERE (CustomerID = @Original_CustomerID) AND (CompanyName = @Original_CompanyName) AND (ContactName = @Original_ContactName OR @Original_ContactName IS NULL AND ContactName IS NULL); SELECT CompanyName, ContactName, CustomerID FROM Customers WHERE (CustomerID = @CustomerID)";
    this.sqlUpdateCommand1.Connection = this.sqlConnection1;
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CompanyName", System.Data.SqlDbType.NVarChar, 40, "CompanyName"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ContactName", System.Data.SqlDbType.NVarChar, 30, "ContactName"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CustomerID", System.Data.SqlDbType.NVarChar, 5, "CustomerID"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CustomerID", System.Data.SqlDbType.NVarChar, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CustomerID", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CompanyName", System.Data.SqlDbType.NVarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CompanyName", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ContactName", System.Data.SqlDbType.NVarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ContactName", System.Data.DataRowVersion.Original, null));
    // 
    // sqlDeleteCommand1
    // 
    this.sqlDeleteCommand1.CommandText = "DELETE FROM Customers WHERE (CustomerID = @Original_CustomerID) AND (CompanyName " +
    "= @Original_CompanyName) AND (ContactName = @Original_ContactName OR @Original_C" +
    "ontactName IS NULL AND ContactName IS NULL)";
    this.sqlDeleteCommand1.Connection = this.sqlConnection1;
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CustomerID", System.Data.SqlDbType.NVarChar, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CustomerID", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CompanyName", System.Data.SqlDbType.NVarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CompanyName", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ContactName", System.Data.SqlDbType.NVarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ContactName", System.Data.DataRowVersion.Original, null));
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(136, 224);
    this.button1.Name = "button1";
    this.button1.TabIndex = 2;
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // frmMain
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(472, 357);
    this.Controls.Add(this.button1);
    this.Controls.Add(this.label1);
    this.Controls.Add(this.txtCustID);
    this.Name = "frmMain";
    this.Text = "测试一";
    this.Load += new System.EventHandler(this.frmMain_Load);
    ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new frmMain());
    } private void sqlDataAdapter1_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e)
    {

    } private void frmMain_Load(object sender, System.EventArgs e)
    {

    } private void button1_Click(object sender, System.EventArgs e)
    {
    this.sqlDataAdapter1.Fill(this.dataSet11,"Customers");
    }
    }
    }
      

  6.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.SqlClient;namespace ch18ex01
    {

    public class frmMain : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TextBox txtCustID;
    private System.Windows.Forms.Label label1;
    private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
    private System.Data.SqlClient.SqlConnection sqlConnection1;
    private ch18ex01.DataSet1 dataSet11;
    private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
    private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
    private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
    private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
    private System.Windows.Forms.Button button1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public frmMain()
    {
    InitializeComponent();
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码