Here is a little more of the code so you can see how i am
trying to set up the DataTable.
' Create DataSet named DsnSentenceStuff.
Dim DsnSentenceStuff As New DataSet
("DsnSentenceStuff")
' Add one DataTable object, WordsinSentence
DsnSentenceStuff.Tables.Add(New DataTable
("WordsinSentence"))
' Create a Table in the dataset named
WordsinSentenceTable
Dim WordsinSentenceTable As DataTable
WordsinSentenceTable = New DataTable
("WordsinSentence")
' Add columns to table WordsinSentenceTable
WordsinSentenceTable.Columns.Add("intWordCount",
GetType(Int32))
WordsinSentenceTable.Columns.Add
("strWordInflect", GetType(String))
WordsinSentenceTable.Columns.Add("intKeyMeanid",
GetType(Int16))
WordsinSentenceTable.Columns.Add
("strTxtLangCode", GetType(String))
WordsinSentenceTable.Columns.Add
("strGestLangCode", GetType(String))
WordsinSentenceTable.Columns.Add
("strTransTxtLangCode", GetType(String))
WordsinSentenceTable.Columns.Add
("strTxtGestHeadWord", GetType(String))
WordsinSentenceTable.Columns.Add
("strKeyHeadWord", GetType(String))
WordsinSentenceTable.Columns.Add("strGestBinary",
GetType(String))
WordsinSentenceTable.Columns.Add
("strTransGestHeadword", GetType(String))
' Set PrimaryKey
WordsinSentenceTable.Columns
("intWordCount").Unique = True
WordsinSentenceTable.PrimaryKey = New DataColumn
() {WordsinSentenceTable.Columns("intWordCount")}
' Insert code to fill tables with columns and
data.
' Binds the DataGrid to the DataSet, displaying
the WordsinSentence table.
'Hmmm??? Why is the right datasource a table and
not a dataset??
'DataGrid2.SetDataBinding
(DsnSentenceStuff, "WordsinSentence")
DataGrid2.DataSource = WordsinSentenceTable
Dim myDataRow As DataRow
Dim i As Integer
For i = 0 To 4
myDataRow = WordsinSentenceTable.NewRow()
myDataRow("intWordCount") = i
myDataRow("strWordInflect") = "Item " +
i.ToString()
myDataRow("intKeyMeanid") = i * 2
myDataRow("strTxtLangCode") = "ASE"
myDataRow("strGestLangCode") = "Item " +
i.ToString()
myDataRow("strTransTxtLangCode") = "Item " +
i.ToString()
myDataRow("strTxtGestHeadWord") = "Item " +
i.ToString()
myDataRow("strGestBinary") = "Item " +
i.ToString()
myDataRow("strTransGestHeadword") = "Item " +
i.ToString()
WordsinSentenceTable.Rows.Add(myDataRow)
Next i
' Not sure I need this unless will update a
database using a data adapter.
'WordsinSentenceTable.AcceptChanges()
' YES! The data row has the data but does it make
it in to the dataset (or is it Data Table)??
TextBox2.Text = myDataRow("intWordCount") & " " &
myDataRow("strWordInflect")
Dim strExpr As String
Dim strSort As String
' strExpr = "intWordCount = 3 & strTxtLangCode =
ASE"
' Sort descending by CompanyName column.
' strSort = "intWordCount ASC"
' Use the Select method to find all rows matching
the filter.
Dim foundRows As DataRow() =
WordsinSentenceTable.Select(strExpr, strSort,
DataViewRowState.Added)
TextBox2.Text = foundRows("strTxtGestHeadWord")
-----Original Message-----
"Bob Achgill" <an*******@discussions.microsoft.com>
schrieb
I would like some example code that shows retrieving
and updating selected column data from a DataTable.
I am sucessful to load and select the whole row of a
DataTable into a datagrid. But can't seem to access
just a specific column on a specific row. Maybe it is a
simple solution that I need.
When I try to receive the data from the
column "strTxtGestHeadWord" into a TextBox like this:
TextBox2.Text = foundRows("strTxtGestHeadWord")
The error I get is:
Value of type 'System.Data.DataRow' cannot be
converted to 'String'.
Do you have Option Strict On? How is foundRows declared?
--
Armin
How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
.