myCommand.Fill(ds, "States");
改成
myCommand.Fill(ds, "Authors");
第二个参数是你查询出来的表名

解决方案 »

  1.   

    谢谢你这么快的回复,但是这个我肯定试过,还是不行
    // SqlConnection myConnection = new SqlConnection("User ID=sa;Initial Catalog=pubs ;Data Source=(local);PassWord=");
    // SqlCommand myCommand = new SqlCommand("select distinct State from Authors", myConnection);
    // ArrayList a = new ArrayList();
    //
    // myConnection.Open();
    //
    // SqlDataReader dr = myCommand.ExecuteReader();
    //
    // while(dr.Read())
    // {
    // a.Add(dr.GetSqlString(0));
    // }
    //
    // dr.Close();
    // myConnection.Close();
    //
    // DropDownList1.DataSource = a;
    // DropDownList1.DataBind();只好这么搞定,但是我很想知道是不是数据绑定会有很多问题????
      

  2.   

    DropDownList1.DataSource= ds.Tables["States"].DefaultView;
    DropDownList1.DataTextField=字段名
    DropDownList1.DataValueField=字段名
    DropDownList1.DataBind();
    这样应该就可以了
      

  3.   

    但是奇怪的很,最开始的代码是微软asp.net快速入门例程给的,这么马虎??
      

  4.   

    DropDownList1.DataSource = ds.Tables["Authors"].DefaultView;
    DropDownList1.DataTextField = ds.Tables["Authors"].Columns[0].ToString();
    DropDownList1.DataValueField = ds.Tables["Authors"].Columns[0].ToString();
    DropDownList1.DataBind();
      

  5.   

    少了
    DropDownList1.DataTextField=字段名
    DropDownList1.DataValueField=字段名