What's wrong UsersTableAdapter.Fill?

Milouvr3

New member
Joined
Jul 17, 2007
Messages
3
Programming Experience
3-5
Private Sub setUserList()
Me.UsersTableAdapter.Fill(Me.MSDataSet.Users)
Dim filtExp As String
filtExp = "GroupID =" & GID
Dim dr As DataRow()
Dim dt As New DataTable()
dt = New DataTable()
dt = MSDataSet.Users.Clone

dr = Me.MSDataSet.Users.Select(filtExp)

Dim a As Integer
For a = 0 To dr.GetUpperBound(0) Step 1
dt.Rows.Add(dr(a))
Next
Me.UsersTableAdapter.Fill(dt)


End Sub
 
What exactly are you trying to do? You haven't explained what's currently happening and what should be happening.
 
I dont normally put much effort into answering a question that hasnt had much effort put into its asking, but i'll comment ever line of your code and see can you work out what is wrong:



VB.NET:
Private Sub setUserList()

'fill the users datatable with the contents of user table in the database
        Me.UsersTableAdapter.Fill(Me.MSDataSet.Users)

'declare a string variable
        Dim filtExp As String

'set the string variable to a value that might not work for filtering a datatable if GID is not a number
        filtExp = "GroupID =" & GID

'declare an array of datarows
        Dim dr As DataRow()

'declare a var for, and assign it a new datatable, pointlessly...
        Dim dt As New DataTable()

'...create another new datatable and replace the previous new datatable with it, also pointlessly...
        dt = New DataTable()

'..because we are going to throw away the new table and re-point this var to a new copy of an existing datatable, without the data
        dt = MSDataSet.Users.Clone

'obtain an array of rows matching the filter string, store in dr
        dr = Me.MSDataSet.Users.Select(filtExp)

'declare an array counter
        Dim a As Integer

'loop to skip over the whole array
        For a = 0 To dr.GetUpperBound(0) Step 1

'add a new row to ourr cloned table, namely this selected row
            dt.Rows.Add(dr(a))

'loop
        Next

'destroy the contents of dt that we have so painstakingly put there, by refilling it with the entire contents of the users table
        Me.UsersTableAdapter.Fill(dt)


    End Sub
 
Youre making it too hard. See attached.

First fill 50, then fill 100.. If anything puzzles you, read the DW2 link in my sig, section on "Creating a Form to Search Data"
 

Attachments

  • SimpleListboxFill.zip
    39.1 KB · Views: 16
i found a way
i used Xsd to set datatables

then i set the dat source of the list to this datatable "uInfo"
then i add this command to the code:
Me.UInfoTableAdapter.Fill(Me.MS_Data.uInfo, UID)
 
Back
Top