PC Review


Reply
Thread Tools Rate Thread

How to connect a DataView to an access database?

 
 
Brad Rogers
Guest
Posts: n/a
 
      30th Dec 2005
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.


 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      30th Dec 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


 
Reply With Quote
 
Brad Rogers
Guest
Posts: n/a
 
      30th Dec 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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      30th Dec 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


 
Reply With Quote
 
Brad Rogers
Guest
Posts: n/a
 
      30th Dec 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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      31st Dec 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?...3-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" <(E-Mail Removed)> 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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>
>>

>
>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      9th Jan 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to connect to Access Database using VPN? Paul Microsoft Access Forms 13 2nd Jan 2007 02:04 AM
how to connect Access Database with VB.net =?Utf-8?B?QWJkdWxsYWggTWFsaWs=?= Microsoft Access 2 31st Oct 2006 01:11 AM
how to connect Access database =?Utf-8?B?QWJkU29s?= Microsoft ADO .NET 5 5th Apr 2005 02:27 PM
Cannot connect to Access Database =?Utf-8?B?YWx0b25icmlkZ2U=?= Microsoft Access Security 0 5th Dec 2004 04:23 PM
how to connect to access database Ken Slovak - [MVP - Outlook] Microsoft Outlook VBA Programming 1 24th Dec 2003 08:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:57 AM.