前端之家收集整理的这篇文章主要介绍了
[VB.NET]关于OleDbDataAdapter的Fill问题,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
关于OleDbDataAdapter的Fill问题 Dim ProgramRightDS As New DataSet Dim ProgramDA As OleDbDataAdapter Dim ProgramRightDA As OleDbDataAdapter ProgramDA = New OleDbDataAdapter( "SELECT PROGRAMID,PROGRAMDESC FROM PROGRAM ORDER BY PROGRAMDESC ",myConnection) ''多表
查询的Select语句 ProgramRightDA = New OleDbDataAdapter( "SELECT PROGRAM.PROGRAMDESC,PROGRAMRIGHTS.RIGHTID FROM PROGRAMRIGHTS,PROGRAM WHERE PROGRAM.PROGRAMID=PROGRAMRIGHTS.PROGRAMID; ",myConnection) ProgramDA.Fill(ProgramRightDS,"PROGRAM ") ProgramRightDA.Fill(ProgramRightDS) ''
提示出错 我想把ProgramRightDA也Fill到ProgramRightDS中,如何实现?ProgramRightDA是一个多表
查询,在Fill时我如何写表名? __________________________________________________________________________ Dim ProgramRightDS As New DataSet
提示的是什么
错误,把
错误信息写出来。 可以用个变通的
方法: 把两个
sql写在一起。 Dim ProgramDA As OleDbDataAdapter ProgramDA = New OleDbDataAdapter( "SELECT PROGRAMID,PROGRAMDESC FROM PROGRAM ORDER BY PROGRAMDESC;SELECT PROGRAM.PROGRAMDESC,PROGRAM WHERE PROGRAM.PROGRAMID=PROGRAMRIGHTS.PROGRAMID ",myConnection) ProgramDA.Fill(ProgramRightDS) __________________________________________________________________________ dataset可以填多个表的啊,表名随便,只要不重复 __________________________________________________________________________ Dim ProgramRightDS As New DataSet Dim ProgramDA As OleDbDataAdapter ProgramDA = New OleDbDataAdapter( "SELECT PROGRAMID,myConnection) ProgramDATableMappings.Add( "PROGRAM1 ","你打算起的第二个表名 "); ProgramDA.Fill(ProgramRightDS,"PROGRAM ") __________________________________________________________________________ Dim ProgramRightDS As New DataSet Dim ProgramDA As OleDbDataAdapter ProgramDA = New OleDbDataAdapter( " SELECT PROGRAMID,PROGRAMDESC FROM PROGRAM ORDER BY PROGRAMDESC; SELECT PROGRAM.PROGRAMDESC,myConnection) ProgramDA.TableMappings.Add( "PROGRAM1 ","PROGRAM ") __________________________________________________________________________ 谢谢!可以了 __________________________________________________________________________
原文链接:https://www.f2er.com/vb/264005.html