问题描述
程序用geRenWuPinGuiShu_MyDataAdpater.Fill(geRenWuPinGuiShu_ds,"gerenwupinguishu");没问题,但用geRenWuPinGuiShu_MyDataAdpater.Update(geRenWuPinGuiShu_ds,"gerenwupinguishu");就出现报错程序如下:privatevoidGeRenWuPinGuiShu_XiuGaiShuJu_Click(objectsender,System.EventArgse){///连接数据库stringgeRenWuPinGuiShu_Cnstr="Password="+PublicClass.publicStringPassWord+";UserID="+PublicClass.publicStringUserName+";InitialCatalog=gerenxinxiku;DataSource="+PublicClass.publicStringServerName;SqlConnectiongeRenWuPinGuiShu_Cn=newSqlConnection(geRenWuPinGuiShu_Cnstr);geRenWuPinGuiShu_Cn.Open();/*-----------------打开数据库表-----------------*/SqlCommandgeRenWuPinGuiShu_cmd=newSqlCommand();geRenWuPinGuiShu_cmd.Connection=geRenWuPinGuiShu_Cn;geRenWuPinGuiShu_cmd.CommandText="SELECT*FROMgerenwupinguishu";SqlDataAdaptergeRenWuPinGuiShu_MyDataAdpater=newSqlDataAdapter(geRenWuPinGuiShu_cmd.CommandText,geRenWuPinGuiShu_Cn);DataSetgeRenWuPinGuiShu_ds=newDataSet();geRenWuPinGuiShu_MyDataAdpater.Update(geRenWuPinGuiShu_ds,"gerenwupinguishu");//将数据集绑定到geRenWuPinGuiShu_DataGrid控件上geRenWuPinGuiShu_DataGrid.SetDataBinding(geRenWuPinGuiShu_ds,"gerenwupinguishu");}
解决方案
解决方案二:
你是不是没fill就update,这样还没有这个表呢
解决方案三:
FiLL了呀
解决方案四:
上边复制漏了,在geRenWuPinGuiShu_MyDataAdpater.Update(geRenWuPinGuiShu_ds,"gerenwupinguishu");上边还有一行geRenWuPinGuiShu_MyDataAdpater.Fill(geRenWuPinGuiShu_ds,"gerenwupinguishu");