DataSet技术 DataTable DataView//*****************************************************************************/// 在数据库vls 中有个 PROVINCE表 其中字段有 PROVINCE_ID/ PROVINCE_CDE/ PROVINCE_NAME ××包含中国34省,市,自治区//*****************************************************************************/From 与ASP.NET 用法一样1.绑定DataGirdstring constr="user id=sa;password=168168;initial catalog=VLS;data source=yu;Connect Timeout=30";SqlConnection mycon=new SqlConnection(constr); string sqlstr="select * from PROVINCE";SqlDataAdapter dap=new SqlDataAdapter(sqlstr,mycon);// 也可以用下面3句 调用 SqlCommand组件//SqlCommand mycomd=new SqlCommand(sqlstr,mycon);//SqlDataAdapter dap=new SqlDataAdapter();//dap.SelectCommand=mycomd; mycon.Open();DataSet ds=new DataSet();dap.Fill(ds,"PROVINCE");mycon.Close();this.DataGrid1.DataSource=ds.Tables[0].DefaultView;this.DataGrid1.DataBind();2.增加string constr="user id=sa;password=168168;initial catalog=VLS;data source=yu;Connect Timeout=30";SqlConnection mycon=new SqlConnection(constr); string sqlstr="select * from PROVINCE";SqlCommand mycomd=new SqlCommand(sqlstr,mycon);mycon.Open();SqlDataAdapter myAdapter=new SqlDataAdapter();myAdapter.SelectCommand=mycomd;DataSet ds=new DataSet();myAdapter.Fill(ds,"PROVINCE");//增加for(int i=0;i<34;i++) 相关文章: 2022-12-23 2022-12-23 2021-10-29 2021-09-10 2021-05-20