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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill Data Rows with values from Database

Status
Not open for further replies.
Mar 14, 2002
711
US
I have done this before when each field was a unique field from a database, but this time I have 3 columns, all named the same, but several rows of data, and I need to fill each field in my .NET page from the database, but I am not sure how to continue...

This is the code I have so far:

Dim mySelectCommand As OleDbCommand = New OleDbCommand("SELECT DISTINCT [All Plants Summary Data].Plant, [All Plants Summary Data].Group, [All Plants Summary Data].[Group Description] FROM [All Plants Summary Data] WHERE [All Plants Summary Data].Plant =? ", conMetrics)

mySelectCommand.Parameters.Add("@Plant", Plant.SelectedItem.Value)

Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(mySelectCommand)

Dim myDataSet = New DataSet()

Dim myDataTable = New DataTable()

myDA.Fill(myDataSet, "[All PLants Summary Data]")

Dim Row As DataRow

If myDataSet.Tables("[All PLants Summary Data]").Rows.Count > 0 Then

Row = myDataSet.Tables("[All PLants Summary Data]").Rows(0)

End If

'GROUP DESCRIPTION FIELD 1

If Row.Item(2) Is DBNull.Value Then
GDESC1.Text = String.Empty
Else
GDESC1.Text = Row.Item(2)
End If

'GROUP ITEM 1

If Row.Item(1) Is DBNull.Value Then
G1.Text = String.Empty
Else
G1.Text = Row.Item(1)
End If

So now I want to continue with "Group Description 2" and "Group Item 2", but how do I tell it to use Row 2, Column 2 and Row 2, Column 1??

Thanks for any help on this one...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top