Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataAdapter Fill command from values in list box only working on first value
 

DataAdapter Fill command from values in list box only working on first value

I have For/while loop that goes through the values in a list box and uses the Fill command to return the data row and display the appropriate columns on the linked components on a form.

It works fine on the first value but not on the second. If I reverse the values in the list box it still works on the 1st value so I know I have data in that matches in the database.

If I bind to a text box and execute the same Fill command it works just fine.

I can't figure out what I am doing wrong. Any ideas? I don't receive any errors it just blanks out all the objects on the form.

Dim I As Long

Dim SerialNum As String

For I = 0 To lbSerialNumber.Items.Count - 1

SerialNum = lbSerialNumber.Items.Item(I).ToString

txtSerialNumber.Text = SerialNum

lbSerialNumber.SelectedIndex = I

Dim MyTableAdapter As New DataSet2TableAdapters.FINALS_DATATableAdapter

MyTableAdapter.Fill(DataSet2.FINALS_DATA, SerialNum)

'TODO: This line of code loads data into the 'DataSet2.GAGE' table. You can move, or remove it, as needed.

Me.GAGETableAdapter.Fill(Me.DataSet2.GAGE)

'TODO: This line of code loads data into the 'DataSet2.LOADCELL_SPECS' table. You can move, or remove it, as needed.

Me.LOADCELL_SPECSTableAdapter.Fill(Me.DataSet2.LOADCELL_SPECS)

'TODO: This line of code loads data into the 'DataSet2.MODELS' table. You can move, or remove it, as needed.

Me.MODELSTableAdapter.Fill(Me.DataSet2.MODELS)

' additional code to print a certificate in Word follows

Next I

Janet Slocombe  Tuesday, May 22, 2007 9:34 PM

Hi Janet Slocombe,

There is a ClearBeforeFill property for each customed TableAdapter. Set it to false and you will get all the data. If this is true, all rows inthe table are removed before retrieving rows from the data source. For more information , you can check the source code of your typed DataSet.

Hope this helps.

Regards

Rong-Chun Zhang  Tuesday, May 29, 2007 5:25 AM

Hi Janet Slocombe,

There is a ClearBeforeFill property for each customed TableAdapter. Set it to false and you will get all the data. If this is true, all rows inthe table are removed before retrieving rows from the data source. For more information , you can check the source code of your typed DataSet.

Hope this helps.

Regards

Rong-Chun Zhang  Tuesday, May 29, 2007 5:25 AM

You can use google to search for other answers

Custom Search

More Threads

• Can't get CellParsing/CellFormatting to work without errors
• How Do I Set a Default Value for a DataGridView Column from Code (C#).
• Updating databound combo box...?
• DataGridView children
• Tying arbitrary query to DataGridView component in VS2005
• N-Tiers application
• DataGridView Checkbox Column
• how to bind image (binary data) into a binding control
• Tab Control
• How to Serialize DataGridViewTextColumn using CodeDomSerializer or any other related classes.