问题描述
问题描述如下:有两个表mps_material_cal和itemdata,要求显示mps_material_cal的itemno字段,条件是mps_material_cal.itemno=itemdata.itemno并且itemdata.mp_code='zz'这些已经在sql查询分析器中验证过了,可是实现。刚才已经讨教过,求得的代码如下,通过编译不报错,现在的问题是:datagridview控件的datagridviewtasks中choosedatasource选项该选择什么呢DataSetds=newDataSet();//连接数据库stringmyConnectionString="DataSource=IBM-715A590BD4E;InitialCatalog=wahaha;PersistSecurityInfo=True;UserID=sa;Password=sa;";//设置数据库连接SqlConnectionmyConnection=newSqlConnection(myConnectionString);//设置数据库操作命令stringmyInsertQuery="selectmps_material_cal.itemno,mps_material_cal.quantityfrommps_material_caljoinitemdataon(mps_material_cal.itemno=itemdata.itemno)whereitemdata.mp_code='zz'";SqlCommandmyCommand=newSqlCommand(myInsertQuery,myConnection);myCommand.Connection=myConnection;//设置SqlCommand实例使用的连接myConnection.Open();//打开数据库//SqlDataAdapterwahahaDataSet1TableAdapters=newSqlDataAdapter(myCommand,myConnection);SqlDataAdapterwahahaDataSet1TableAdapters=newSqlDataAdapter();wahahaDataSet1TableAdapters.SelectCommand=myCommand;wahahaDataSet1TableAdapters.Fill(ds);myConnection.Close();//returnds;
解决方案
解决方案二:
就是程序和控件怎么样联系在一起~~现在程序代码和控件是分离开的