您的位置:程序门 -> .net技术 -> vb.net



dataset绑定datagridview,如何将更改的数据保存回数据库???


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


dataset绑定datagridview,如何将更改的数据保存回数据库???[已结贴,结贴人:yeguoshun37]
发表于:2007-02-06 18:55:17 楼主
dim   strcon   as   string                
                strcon   =   "provider=microsoft.jet.oledb.4.0;data   source= "   +   my.computer.filesystem.currentdirectory   +   "\config.mdb "
                     
                dim   mycon   as   new   data.oledb.oledbconnection(strcon)
                mycon.open()
                mycom.connection   =   mycon
                dim   cmd   as   new   oledb.oledbcommand
                              dim   strsql   as   string
                strsql   =   "select   *   from   表1 "

                adpt   =   new   oledb.oledbdataadapter(strsql,   mycon)
                dim   mytable1   as   datatable
                adpt.fill(mydataset,   "table ")
                mytable1   =   mydataset.tables( "table ")
                datagridview1.datasource   =   mytable1


以上代码是把数据绑定到datagridview1上,请问如何把程序运行过程中datagridview1上更改的数据同步更新到数据库 "表1 "中呢???vb2005.请高手指点谢谢!!!
发表于:2007-02-06 19:07:191楼 得分:10
datatable   mytable1   =   datagridview1.datasource   as   datatable;
if(mytable1.getchanges()   !=   null)
{
      adpt.update(mytable1.getchanges());
}

c#语法,vb记不太清了,大概这样
发表于:2007-02-06 19:16:382楼 得分:10
dim   mytable1   as   datatable   =   datagridview1.datasource
if   mytable1.getchanges()   <>   null   then
      adpt.update(mytable1.getchanges())
end   if


快速检索

最新资讯
热门点击