Need help with Dataset

bonedoc

Well-known member
Joined
May 4, 2006
Messages
112
Programming Experience
Beginner
I am trying to open a column named "cn" in table "Notes" using a dataset. This what I have so far, but it does not work. It says "Notes is not a part of dataset". Can someone tell me how to make "notes" a table in the dataset or how I may be doing things wrong? Thanks for any help.

Dim MyDataAdapter as OleDbDataAdapter
Dim MyCommand as New OledbCommand
Dim MyDataSet as DataSet
MyCommand.CommandType = CommandType.Text
MyCommand.CommandType = xxxxxx
MyCommand.SelectCommand = MyCommand
MyDataAdapter.Fill(MyDataSet)


Dim x as integer

x= MyDataSet.Notes.Rows(0).Item(cn)
 
When you write a .Fill line, you need to also specify a table name. A dataset contains multiple tables so when you write a .Fill line for your dataset, you need to specify which table you want filled. In your case, you would want your .Fill line to read:

VB.NET:
MyDataAdapter.Fill(MyDataSet, "Notes")

Then you will have a table within your dataset called "Notes". Then in your last line of code, you can write it out like this:

VB.NET:
x = MyDataSet.Tables("Notes").Rows(0).Item(cn)

Your code should work fine after those modifications.
 
Back
Top