标签:datagridview style blog http ar io color os sp
private void Form1_Load(object sender, EventArgs e) { string strCon = "Server=localhost;User Id=sa;Pwd=;DataBase=my";//定义数据库连接字符串 SqlConnection sqlcon = new SqlConnection(strCon);//实例化数据库连接对象 SqlDataAdapter sqlda_1 = new SqlDataAdapter("select * from S",sqlcon);//实例化数据库桥接器对象 SqlDataAdapter sqlda_2 = new SqlDataAdapter("select * from Y",sqlcon);//实例化数据库桥接器对象 DataSet myds = new DataSet();//实例化数据集对象 sqlda_1.Fill(myds,"table_name_1");//填充数据集中的指定表 sqlda_2.Fill(myds, "table_name_2");//填充数据集中的指定表 //dataGridView1.DataSource = myds.Tables["table_name_1"];//为dataGridView1指定数据源 //dataGridView1.DataSource = myds.Tables[0];//为dataGridView1指定数据源table_name_1<=>0 //dataGridView1.DataSource = myds.Tables["table_name_2"];table_name_2<=>1 dataGridView1.DataSource = myds.Tables[1]; }
标签:datagridview style blog http ar io color os sp
原文地址:http://www.cnblogs.com/leijiangtao/p/4169485.html