这是个ComboBox的绑定问题..代码如下.using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;namespace WindowsApplication3
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button button1;
DataSet myDataSet;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
GetConnect ( );
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
// 
// comboBox1
// 
this.comboBox1.Location = new System.Drawing.Point(96, 72);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 0;
// 
// button1
// 
this.button1.Location = new System.Drawing.Point(112, 152);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Controls.Add(this.comboBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion
private void GetConnect ( )
{

// 设定数据连接字符串,此字符串的意思是打开Sql server数据库,服务器名称为server1,数据库为data1
string strCon = "Server=localhost;database=Tayside_University;user id=sa;password=" ;
SqlConnection myConn = new SqlConnection ( strCon ) ;
myConn.Open ( ) ;
string strCom = "select collegename from college" ;
//创建一个 DataSet
myDataSet = new DataSet ( ) ;
//用 OleDbDataAdapter 得到一个数据集
SqlDataAdapter myCommand = new SqlDataAdapter ( strCom , myConn ) ;
//把Dataset绑定person数据表
myCommand.Fill ( myDataSet , " College " ) ;
//关闭此OleDbConnection

}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} private void button1_Click(object sender, System.EventArgs e)
{
comboBox1.DataSource = myDataSet ;
comboBox1.DisplayMember = "College.CollegeName" ;
comboBox1.ValueMember = "College.CollegeName" ;
}
}
}点击按钮就报错..
未处理的“System.ArgumentException”类型的异常出现在 system.windows.forms.dll 中。其他信息: 无法创建字段 College 的子列表。