Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Releated Datagrids VB windows problem.

Status
Not open for further replies.

SBTBILL

Programmer
May 1, 2000
515
0
0
US
I've set up a 3 grid screen. The top grid should control the other 2 grids.
I get the current record of the top grid with this line.

mitem = dv1(cma.Position)("sponsor_id")

It bings me the correct information

I then call 2 routines to populate 2 datatables

I have code to empty the datatables at the beginning of each routine
a_tmpf3.Clear()

I run a select statement to get the data I want.

I then clear the grids and reset the data source
grddistributors.EndEdit()
grddistributors.DataSource = Nothing
grddistributors.Rows.Clear()
grddistributors.Refresh()
grddistributors.DataSource = a_tmpf3.DefaultView 'G2.Tables("thedists")
grddistributors.Refresh()

No mater what I've tried what happens is that the previous data stays and the new data is added. All I want is the new data.






 
Please show the code where you fill the datatables.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
grabline = "Select gs.theyear, "
grabline = grabline & " gs.sponsor_id, "
grabline = grabline & " gs.lvl, "
grabline = grabline & " gs.april, "
grabline = grabline & " gs.may, "
grabline = grabline & " gs.june, "
grabline = grabline & " gs.july, "
grabline = grabline & " gs.august, "
grabline = grabline & " gs.september, "
grabline = grabline & " gs.october, "
grabline = grabline & " gs.november, "
grabline = grabline & " gs.december, "
grabline = grabline & " gs.january, "
grabline = grabline & " gs.february, "
grabline = grabline & " gs.march, "
grabline = grabline & " gs.total "
grabline = grabline & " from distributors.dbo.history_gsv_by_levels gs "
grabline = grabline & " left outer join distributors.dbo.distributors gh "
grabline = grabline & " on "
grabline = grabline & " gs.sponsor_id = "
grabline = grabline & " gh.dist_id "
grabline = grabline & " left outer join distributors.dbo.diststats gd "
grabline = grabline & " on "
grabline = grabline & " gs.sponsor_id = gd.dist_id "
'If Len(Trim(mcriteria)) > 0 Then
'grabline = grabline & " where " & mcriteria
'End If
grabline = grabline & " where gs.theyear = '" & myear & "' "
grabline = grabline & " and "
grabline = grabline & " gs.sponsor_id = " & mitem
grabline = grabline & " order by gs.sponsor_id,gs.lvl "
Try
GRAB.Open()
Catch
End Try

Dim grab2a As New SqlCommand(grabline, GRAB)
'
Dim G1a As New SqlDataAdapter(grab2a)
Dim G2a As New DataSet
'
G1a.Fill(G2a, "THElevels")
 
I think I've found the problem. I defined the dataset at the start of the program rather then in the subroutine. That caused the table to just grow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top