关于DATASET的一个奇怪的问题

jatim 2006-04-19 03:38:23
Public Class SALES

Private connstr As String = "Provider=sqloledb;Data Source=jfc08;Initial Catalog=ufdata_100_2006;User Id=sa;Password=1234"
Private sql = "select * from [so_somain] order by [dDate]"
Private conn As New OleDbConnection(connstr)
Private dst As New DataSet
Private cmd As OleDbCommand
Private objdataview As DataView
Private CM As CurrencyManager
Private adapter As New OleDbDataAdapter(sql, conn)

//mymove()是我自己建的一个模块



Private Sub mymove()

Dim sql1 As String = "select * from [so_sodetails] where [csocode]='" & Label10.Text & "' "
Dim adapter1 As New OleDbDataAdapter(sql1, conn)
Dim dst1 As New DataSet
adapter1.Fill(dst1, "订单明细")
SalesDg.DataSource = dst1.Tables("订单明细")

End Sub


Private Sub SALES_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

conn.Open()

adapter.Fill(dst, "销售订单")
CM = CType(BindingContext(dst, "销售订单"), CurrencyManager)

'SalesDg.DataSource = dst.Tables("销售订单")
'objdataview = New DataView(dst.Tables("销售清单"))


Label10.DataBindings.Add("Text", dst, "销售订单.cSOCode")
Label11.DataBindings.Add("Text", dst, "销售订单.cdefine1")
Label12.DataBindings.Add("Text", dst, "销售订单.cbustype")
Label13.DataBindings.Add("Text", dst, "销售订单.dDate")
Label14.DataBindings.Add("Text", dst, "销售订单.cdefine2")
Label15.DataBindings.Add("Text", dst, "销售订单.ccusname")
Label16.DataBindings.Add("Text", dst, "销售订单.cbustype")
Label17.DataBindings.Add("text", dst, "销售订单.cdepcode")
'Label19.DataBindings.Add("text", dst.Tables(0).Rows.Item())
Label22.Text = CM.Count - 1

Call mymove()

End Sub


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CM.Position = 0
Call mymove()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
CM.Position -= 1
Call mymove()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

CM.Position += 1
Call mymove()

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
CM.Position = CM.Count - 1
Call mymove()
End Sub

我在mymove 模块里定义一个新的DST1,可以根据主表so_somain里记录的移动而在DATAGRID里显示相应的只表内容

但是如果我直接使用DST,mymove的模块为

Private Sub mymove()
Dim sql1 As String = "select * from [so_sodetails] where [csocode]='" & Label10.Text & "' "
Dim adapter1 As New OleDbDataAdapter(sql1, conn)
adapter1.Fill(dst, "订单明细")
SalesDg.DataSource = dst.Tables("订单明细")

End Sub

子表就在DATAGRID上就不会变化.

请各位大虾指点一下
...全文
65 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jatim 2006-04-19
搞好了,只要加上一句 dst.tables.clear()就行了
  • 打赏
  • 举报
回复
copico 2006-04-19
Private Sub mymove()
Dim sql1 As String = "select * from [so_sodetails] where [csocode]='" & Label10.Text & "' "
Dim adapter1 As New OleDbDataAdapter(sql1, conn)
Dim dt as new DataTable
adapter1.file(dt)
DataGrid1.datasource=dt

End Sub

'楼主换上面的方法试试
  • 打赏
  • 举报
回复
相关推荐
发帖
VB
加入

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
申请成为版主
帖子事件
创建了帖子
2006-04-19 03:38
社区公告
暂无公告