Im trying to understand DataView, to make a couple of lists of sorted data.

The 3 textbooks I have on .net dont have dataview in the index even.

Ive started by doing a database wizard. it finds the .mdb file and formats
the schema and genetated a program, I put a simple grid view in the form1
and pointed its source at the dataset.

But now I have to use DataView. Ive tried making a DataTable, and assigning
it to the dataset which only has the one table. I hook the dataview to a
second gridView. It doesnt complain, runs fine, but there is no data in the
gridView. I wired the gridView to the DataTable? still no data there.

Im searching the docs on how to use the DataView, have an example, but the
example builds up the table from scratch; I want to fill it with 2 specific
columns from the one table in the .mdb database.

Nothing Ive done gets the data into the 2nd gridView. I can manually add
columns to it, but I want the data from 2 specific columns. Seems easy.

Any suggestions appreciated.

Re: How to connect a DataView to an access database? by Cor

Cor
Fri Dec 30 01:30:10 CST 2005

Brad,

There are plenty of methods to set a dataview to the datatable.

By default the datatable has inbuild a property DefaultView. This is from
the type Dataview.

Can you explain us a little bit more how you try to create your dataview.

Cor



Re: How to connect a DataView to an access database? by Brad

Brad
Fri Dec 30 01:59:32 CST 2005

Hi Cor,

Thanks, the goal is to just display 2 columns from one table that has 10?
columns.

I must use the DataView somehow to do it.

I was able to cast/create a Data Table from my access.mdb database dataset.

So there is the DataTable. It has ALL the columns.

I have a 2nd GridView, created a DataView called thisview and said
thisview.RowStateFilter = DataViewRowState.Changed

so when I change an item in the first grid, it pops up on that grid.
cool.

Ive made a DataView and send the contents to a GridView, and played with
some filtering. But I want ONLY 2 columns, and in the columns want to maybe
change text to BOLD based on sorting criteria.

So now I want a GridView that has 2 columns, and those must be from 2
columns in the main DataTable.

Do I have to create a new DataTable? manually enter column names and ?

isnt there a way to say

dim DT as new data table
DT.Columns = (MyTable, ("item", "description") ?
DT.fill

But that doesnt make sense.

Why cant I say
dim DV as new DataView
DV.columns.add(MyTable, (0), (5)) 'adds only columns indexed 0, 5

Me.DataGrid2.datasource = DV

and then it works?? I try variations of this, and have been trying for over
a week, I wont give up until it works.

thanks again






"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:umgELLRDGHA.2664@TK2MSFTNGP15.phx.gbl...
> Brad,
>
> There are plenty of methods to set a dataview to the datatable.
>
> By default the datatable has inbuild a property DefaultView. This is from
> the type Dataview.
>
> Can you explain us a little bit more how you try to create your dataview.
>
> Cor
>
>



Re: How to connect a DataView to an access database? by Cor

Cor
Fri Dec 30 02:47:09 CST 2005

Brad,

You cannot use the dataview to select columns.

However to give you a further answer it has to be clear what kind of grid
you are using because I become confused about that in your answer.

A GridView for ASPNET
A DataGrid WindowsForm
A DataGridView
A DataGrid for ASPNET

I assume it is a GridView for ASPNet with which I have no expirience yet.

Cor



Re: How to connect a DataView to an access database? by Brad

Brad
Fri Dec 30 11:59:17 CST 2005

Cor,

I was wondering about columns, I thought there was only 1 grid view control,
the one found in winforms in the designer view. It doesnt matter how its
displayed.

The important part here is the DataView itself

Its not in my textbooks so I cannot easily read up on it. I do have
examples on making the .mdb connection and dataset. So In memory Ive got
the Dataset.

I could make a new table in Access with just those 2 columns? but thats not
allowed.

So now it looks like Ive got to copy across selected columns from the table,
and make a new table.

Lets say I make a new table with 2 columns. Now I want to fill those with
the columns they represent from the Master column. How is this done??

Do I have to use recursiveness or recursion to say master table
column(3).row(x) = secondtable column(0).row(x) ??

There is no smart FILL routine?

Im not familiar with asp.net but hopefully soon.

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:eMEJM2RDGHA.2820@TK2MSFTNGP11.phx.gbl...
> Brad,
>
> You cannot use the dataview to select columns.
>
> However to give you a further answer it has to be clear what kind of grid
> you are using because I become confused about that in your answer.
>
> A GridView for ASPNET
> A DataGrid WindowsForm
> A DataGridView
> A DataGrid for ASPNET
>
> I assume it is a GridView for ASPNet with which I have no expirience yet.
>
> Cor
>
>



Re: How to connect a DataView to an access database? by Cor

Cor
Sat Dec 31 02:07:55 CST 2005

Brad,

Although it are different classes are all the DataClasses thight connected
to each other. Therefore to help you I have to know what kind of datagrid.
(And if it is a GridView I cannot give you all the information just because
I don't know it yet).

However.

The dataview is the same as the inbuild DefaultView property from a
DataTable. It gives a view on the rows of that table, in fact it has a
rowfilter and a sort property in it.

A benefit is that you can create more views on a table yourself. The
dataview holds as well a lot of information itself. In Net 2.0 you can copy
the rows in the DataView to a new DataTable only containing the filterend
views with the method .ToTable. In Net 1.x you have to go thru the rows from
the dataview for that using than (because a datarow cannot have more
references than one to a table), the method DataRow.ImportRow.

Maybe is this the key for your problems with the DataView. A datarow holds
no information about the columns it contains. The ColumnsInformation is
written in the ColumnCollection from a DataTable. So if the DataView needs
information about a column it uses, than there has to be done internally:
DataRowView->DataTable->ColumnCollection.

Here a very simple sample with a dataview which hide a column on our
website.

http://www.vb-tips.com/default.aspx?ID=76a81eb8-ea2d-48f4-99c3-a3539697edbd

the datatable.defaultview is the same as
dim datatable as new datataview(dt)
where the last is an extra filter.

I hope this gives some ideas

Cor


"Brad Rogers" <bradz1234.nspam@yahoo.com> schreef in bericht
news:Vzetf.28$yW1.11@trnddc05...
> Cor,
>
> I was wondering about columns, I thought there was only 1 grid view
> control,
> the one found in winforms in the designer view. It doesnt matter how its
> displayed.
>
> The important part here is the DataView itself
>
> Its not in my textbooks so I cannot easily read up on it. I do have
> examples on making the .mdb connection and dataset. So In memory Ive got
> the Dataset.
>
> I could make a new table in Access with just those 2 columns? but thats
> not
> allowed.
>
> So now it looks like Ive got to copy across selected columns from the
> table,
> and make a new table.
>
> Lets say I make a new table with 2 columns. Now I want to fill those with
> the columns they represent from the Master column. How is this done??
>
> Do I have to use recursiveness or recursion to say master table
> column(3).row(x) = secondtable column(0).row(x) ??
>
> There is no smart FILL routine?
>
> Im not familiar with asp.net but hopefully soon.
>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:eMEJM2RDGHA.2820@TK2MSFTNGP11.phx.gbl...
>> Brad,
>>
>> You cannot use the dataview to select columns.
>>
>> However to give you a further answer it has to be clear what kind of grid
>> you are using because I become confused about that in your answer.
>>
>> A GridView for ASPNET
>> A DataGrid WindowsForm
>> A DataGridView
>> A DataGrid for ASPNET
>>
>> I assume it is a GridView for ASPNet with which I have no expirience yet.
>>
>> Cor
>>
>>
>
>



Re: How to connect a DataView to an access database? by sam

sam
Sun Jan 08 16:01:40 CST 2006


Brad,

You can not filter the columns of a dataview. You can change som
datagridstyles to hide the columns.

http://tinyurl.com/7vbr7

That article shows you how to hide the columns of a datagrid.

'***************************
You can also create a datatable with only the columns you need b
specifying only the desired columns in the SQL query.

"SELECT col1, col1 FROM tablename"

'***************************
You cold create a new datatable and add columns to it and then copy th
rows.

VB.NET
dim dtOrg as datatable
'code that creates and fills the original datatable

dim dt as new datatable
'Repeat this for each column you want to add
dt.columns.add("columnname", dtorg.columns("columnname").gettype())
'*
'Then to copy all the rows from the original table to the new table
dim drNew as datarow
for each dr as datarow in dtOrg.rows()
drNew = dt.newrow()
for each col as datacolumn in dt.columns()
drnew(col) = dr(col.columnname)
next 'col
dt.rows.add(drnew)
next 'd

--
sa
-----------------------------------------------------------------------
sam's Profile: http://www.hightechtalks.com/m67
View this thread: http://www.hightechtalks.com/t231927


Re: How to connect a DataView to an access database? by Cor

Cor
Mon Jan 09 02:04:36 CST 2006

Brad,

I am glad Sam answered you. I thought it was there, could not find it
anymore and thought I had dreamed it. I found it later, and than I could not
find your question anymore to make a quick correction..

You can select Columns with a dataview in Net 2.0

Problem is that it is not easy to find in MSDN

It is in the 3th overloaded method ToTable

http://msdn2.microsoft.com/en-us/library/h2b6ehaa.aspx

Sorry for giving you not the most optimal answer.
(The given answer works as well)

Cor