datagridview控件的问题 显示两个表的问题
问题描述如下:有两个表mps_material_cal和itemdata ,要求显示mps_material_cal的itemno字段,条件是mps_material_cal.itemno=itemdata.itemno并且 itemdata.mp_code='zz'这些已经在sql查询分析器中验证过了,可是实现。刚才已经讨教过,求得的代码如下,通过编译不报错,
现在的问题是:datagridview控件的datagridview tasks中choose datasource选项该选择什么呢
DataSet ds = new DataSet();
//连接数据库
string myConnectionString = "Data Source=IBM-715A590BD4E;Initial Catalog=wahaha;Persist Security Info=True;User ID=sa;Password=sa;";
//设置数据库连接
SqlConnection myConnection = new SqlConnection(myConnectionString);
//设置数据库操作命令
string myInsertQuery = "select mps_material_cal.itemno,mps_material_cal.quantity from mps_material_cal join itemdata on(mps_material_cal.itemno=itemdata.itemno) where itemdata.mp_code='zz'";
SqlCommand myCommand = new SqlCommand(myInsertQuery,myConnection);
myCommand.Connection = myConnection; //设置 SqlCommand实例使用的连接
myConnection.Open(); //打开数据库
//SqlDataAdapter wahahaDataSet1TableAdapters = new SqlDataAdapter(myCommand,myConnection);
SqlDataAdapter wahahaDataSet1TableAdapters = new SqlDataAdapter();
wahahaDataSet1TableAdapters.SelectCommand = myCommand;
wahahaDataSet1TableAdapters.Fill(ds);
myConnection.Close();
//return ds; --------------------编程问答-------------------- 就是程序和控件怎么样联系在一起~~现在程序代码和控件是分离开的
补充:.NET技术 , C#