473,395 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Naive Database Question

I use VB.Net in VS2005 and rarely use databases.

I have a database to which I open a connection in my application (using
ADO). Once I have the connection, I loop through each table in the database
using a command string ("Select * from .) and a DataAdapter to populate a
DataSet. I then close the connection.

If I understand this correctly, I now have a copy of the database in memory.
I cannot seem to find a way to query this DataSet to limit the rows and
columns that I want to see in my DataGridView. Using
DataSet.Tables.Select( , ) I can limit the number of rows based on a
criterion, but cannot seem to limit the number of columns.

Am I trying to do something that is not possible? If it is possible, please
offer some suggestions. Or, do I have to re-open the connection and
re-query the original database?

Keith Rebello.
Jun 27 '08 #1
5 872
Keith Rebello wrote:
I use VB.Net in VS2005 and rarely use databases.

I have a database to which I open a connection in my application
(using ADO). Once I have the connection, I loop through each table
in the database using a command string ("Select * from .) and a
DataAdapter to populate a DataSet. I then close the connection.

If I understand this correctly, I now have a copy of the database in
memory. I cannot seem to find a way to query this DataSet to limit
the rows and columns that I want to see in my DataGridView. Using
DataSet.Tables.Select( , ) I can limit the number of rows based on a
criterion, but cannot seem to limit the number of columns.

Am I trying to do something that is not possible? If it is possible,
please offer some suggestions. Or, do I have to re-open the
connection and re-query the original database?
Normally you would just set the datagridview to display the columns of interest,
regardless of how many columns are actually in the datarows you are using as a
datasource.
Jun 27 '08 #2
Windows or web application ? In both case you can explicitely define which
columns you want to see (see the Columns collection).

Anyway, this is really not how a DataSet should be used. See this rather as
a "cache" rather than a "copy". The idea is rather to keep around the rows
the user needs at a given time and to move them back and forth in the
dataset or to the db as needed, note to copy the whole db...

--
Patrice

"Keith Rebello" <kr******@corefundamentals.coma écrit dans le message de
groupe de discussion : YM*************@newsfe24.lga...
I use VB.Net in VS2005 and rarely use databases.

I have a database to which I open a connection in my application (using
ADO). Once I have the connection, I loop through each table in the
database using a command string ("Select * from .) and a DataAdapter to
populate a DataSet. I then close the connection.

If I understand this correctly, I now have a copy of the database in
memory. I cannot seem to find a way to query this DataSet to limit the
rows and columns that I want to see in my DataGridView. Using
DataSet.Tables.Select( , ) I can limit the number of rows based on a
criterion, but cannot seem to limit the number of columns.

Am I trying to do something that is not possible? If it is possible,
please offer some suggestions. Or, do I have to re-open the connection
and re-query the original database?

Keith Rebello.

Jun 27 '08 #3
Thanks Steve.

The problem I have is that the DataGridView will have a different number of
columns and column header names dependent on which table in the dataset I
wish to query. That is why it would be nice to be able to query the DataSet
on a table-by-table basis and have the DataGridView display only pertinent
information.

Keith Rebello

"Steve Gerrard" <my********@comcast.netwrote in message
news:OI******************************@comcast.com. ..
Keith Rebello wrote:
>I use VB.Net in VS2005 and rarely use databases.

I have a database to which I open a connection in my application
(using ADO). Once I have the connection, I loop through each table
in the database using a command string ("Select * from .) and a
DataAdapter to populate a DataSet. I then close the connection.

If I understand this correctly, I now have a copy of the database in
memory. I cannot seem to find a way to query this DataSet to limit
the rows and columns that I want to see in my DataGridView. Using
DataSet.Tables.Select( , ) I can limit the number of rows based on a
criterion, but cannot seem to limit the number of columns.

Am I trying to do something that is not possible? If it is possible,
please offer some suggestions. Or, do I have to re-open the
connection and re-query the original database?

Normally you would just set the datagridview to display the columns of
interest, regardless of how many columns are actually in the datarows you
are using as a datasource.

Jun 27 '08 #4
Thanks Patrice. From your post, it makes sense for me to re-connect to and
re-query the database.
For completeness, it is a Windows application and the database is small in
size and is only a small component of the application.

Keith Rebello.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:F4**********************************@microsof t.com...
Windows or web application ? In both case you can explicitely define which
columns you want to see (see the Columns collection).

Anyway, this is really not how a DataSet should be used. See this rather
as a "cache" rather than a "copy". The idea is rather to keep around the
rows the user needs at a given time and to move them back and forth in the
dataset or to the db as needed, note to copy the whole db...

--
Patrice

"Keith Rebello" <kr******@corefundamentals.coma écrit dans le message de
groupe de discussion : YM*************@newsfe24.lga...
>I use VB.Net in VS2005 and rarely use databases.

I have a database to which I open a connection in my application (using
ADO). Once I have the connection, I loop through each table in the
database using a command string ("Select * from .) and a DataAdapter to
populate a DataSet. I then close the connection.

If I understand this correctly, I now have a copy of the database in
memory. I cannot seem to find a way to query this DataSet to limit the
rows and columns that I want to see in my DataGridView. Using
DataSet.Tables.Select( , ) I can limit the number of rows based on a
criterion, but cannot seem to limit the number of columns.

Am I trying to do something that is not possible? If it is possible,
please offer some suggestions. Or, do I have to re-open the connection
and re-query the original database?

Keith Rebello.


Jun 27 '08 #5
Keith Rebello wrote:
>
The problem I have is that the DataGridView will have a different
number of columns and column header names dependent on which table in
the dataset I wish to query. That is why it would be nice to be able
to query the DataSet on a table-by-table basis and have the
DataGridView display only pertinent information.
If you like the auto-generated columns, it should not be hard to loop through
the columns collection after binding a different datasource, and setting visible
to false for the columns you don't want to see - or removing them, for that
matter.

Or you can take control outright, and set AutoGenerateColumns to false. Then
when you change datasource, clear the columns and setup the ones you want. Don't
be fooled into thinking that AutoGenerateColumns does anything different: it
just finds the table's column collection, and loops through, setting up a grid
column for each table column. Doing it yourself gives you a much finer level of
control on a number of properties, such as the header text and format, as well
as control over which columns to show.

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rory Campbell-Lange | last post by:
I have a number of web applications which have a large amount of their logic written in plpgsql. For each particular application I have a separate instance of a database. If I need to update...
3
by: johan2sson | last post by:
The documentation for PyThreadState_SetAsyncExc says "To prevent naive misuse, you must write your own C extension to call this". Anyone care to list a few examples of such naive misuse? Johan
17
by: Christopher Benson-Manica | last post by:
Some recent posts got me thinking about how one might have dealt with simplistic malloc() implementations which might return NULL for a 64K request but might accept two 32K requests or four 16K...
1
by: waqasahmd | last post by:
Hi all, I happen to propose a DBMS, the requirement is that we have 1.6million rows in DB having 15 simple columns and at worse we need to come compare 10,000 rows(trasactions) one by one with...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.