能这样把两个数据表填充到一个dataset吗?
Public Function GetChildBoard(ByVal ClassID As Integer)
sql1 = "SELECT * FROM Board where BoardClassID= " & ClassID & " order by BoardClassID "
ADA = New OleDbDataAdapter(sql1, conn)
Dim ADS As New DataSet
ADA.Fill(ADS, "Board ")
sql2 = "SELECT TOP 1 title, username, savedate FROM articles WHERE parentid=0 and BoardID= " & ClassID & " ORDER BY itemid DESC "
Dim ADA2 As OleDb.OleDbDataAdapter
ADA2 = New OleDbDataAdapter(sql2, conn)
ADA2.Fill(ADS, "Articles ")
conn.Close()
Return ADS
End Function
能这样把两个数据表填充到一个dataset吗?这样Return回来的ADS是否有两个表?
------解决方案--------------------做个联表不就行了吗?
------解决方案--------------------完全可以
你的ADS可以放n个表
------解决方案--------------------是的,可以这样Fill,回来是包含两个DataTable
C#语法是这样的
Textbox.Text = ds.Tables[ "Products "].DefaultView[0][ "Name "].ToString()
VB 是不是这样啊
Textbox.Text = ds.Tables( "Products ").DefaultView(0)( "Name ").ToString
ds.Tables[ "Products "].DefaultView[0] 获取第一行
------解决方案--------------------可以
------解决方案--------------------ADA2.Fill(ADS, "表名 ")DatSet里可以放N个表!随你喜欢!
------解决方案--------------------ds.Tables[ "Products "].Rows[i][ "字段名 "]就可以取到你想要的字段值了
------解决方案--------------------dataset.tables(0 表索引或表名).rows(行索引).item(字段名)