DataGrid / DataSet Issue

  • Thread starter Thread starter youngster94
  • Start date Start date
Y

youngster94

Hi all,

I'm having a little trouble with some code Im writing and Im thinking
there has to be an easy fix. What Ive done is fill a dataset via 3
odbcdataadapters. The dataset is also the datasourse for a datagrid.
When I run the program, the datagrid is nothing more than an empty box
with a graybox in the top left corner. If I explode the graybox, I
have the choice of choosing the odbcdataadapter, and once I select an
adapter and click it, the grid fills with all the correct info. This
all works the way it is meant to.

Heres the problem. I've created a combobox that automatically fills
with all the available odbcdataadapters. The idea is to let the end
user choose here instead of having to explode the graybox.

If I code DataGrid3.DataSource = DataSet11.SO_03SOHistoryHeader

For example, it works like a champ and fills the grid.


However, I need something like:


Dim mySelection as string = combobox1.selectedtext.tostring
'(say user selected "SO_03SOHistoryHeader" - same as above)

DataGrid3.DataSource = DataSet11.mySelection
"ERROR - mySelection is not a member of DataSet11"

This obviously does not work. I cant figure out how to implement a
variable into the statement.



Ive also tried:

With DataSet3
.DataSource = DataSet11
.DataMember = mySelection

End with

This also does not work, however is runs without reporting an error


Any help will be greatly appreciated.


Thanks,

Josh
 
Josh,

Two things, don't use ODBC however when it is Oracle. Oracleclient. When it
is SQL SQLClient, and all others OleDB if possible (and that is mostly).

Have for your problem a look at the dataview. Be aware that that is not a
seperate table however a view on it. As it is included in every datatable as
datatable.defaultview.

http://msdn.microsoft.com/library/d...rlrfsystemdatadataviewclassrowfiltertopic.asp

I point you directly on the rowfilter because that is what you need when you
solve your solution using this to see the class just click on that in top of
the page by overview.

(There are of course much more methods)

I hope this helps,

Cor
 
Cor,

Thanks for the input. The database I'm using is actually MAS90 by
Best. I'm writing a little application to grab data as needed (read
only) from different tables and bring it together in one datagrid where
it can then be further manipulated by the user. The problem is that I
have no way of knowing which tables are needed - this is all done at
runtime - and I don't want to fill all tables because there is a
tremendous amount of tables and data. So what I've done is created a
listbox that is filled with all the table names when the form loads
with the idea that the user can choose the tables they need. To fill a
datagrid for example, I would then us something like:

dim exampleTable as string


exampleTable = listbox1.SelectedItem 'user selects table from list

DataGrid1.DataSource = DataSet11.exampleTable


In theory it works for me, but I cant seem to convince VB.Net to go
along with it.

Thanks again and I'll research the dataview.

Josh
 
Youngster,

Probably has this nothing to do with the dataview, however not difficult to
achieve/

Create a datatable with the text and the name of the tables.

From that you make just a simple connection string.

"Select * from " & valuemember.listbox

Do a dataset fill
Bind that to your dataset.
And you are almost ready.
Be aware that this is a very primitive way of use.

If you want more information reply.

Than maybe I try to make a little sample.
However not any more tonight,

Cor
 
Thanks Cor.
The connection string is where I went wrong. Believe it or not, I used
Microsoft Excel to connect to the database where I chose the tables I
needed and then ran a query to get the data I wanted- after which I
saved the query and then viewed the connection string it automatically
created to connect to the database. It turns out I was leaving out a
relevant table. I also got a list from a MAS90 rep of all the tables,
how they are linked, and what tables you need to include to run a
query. This helped tremendously because I came to find that tables
appearing to be master tables, were not master tables at all. For
example in this case I was using the SalesOrderEntry table and the
SO_UDF table. Well it turns out that there is a SalesOrderEntryDetail
table which is the master table linking these two tables together. I
could have never figured this out on my own.

Thanks for you time and help one this one.
 
Back
Top