Re: Using queries in a table adaptor?
- From: Michael D. Reed <chaskamn@xxxxxxxxxxxxx>
- Date: Mon, 14 Aug 2006 12:14:02 -0700
Cor
Let me be clearer, forget about the grids and displaying the data. I just
need to get some values out of columns in a query.
The setup:
In an XDS file, I have a table adaptor name [Drive Packages]
To this table adaptor, using the query wizard I have added several queries
two are:
One used in the default Fill and GetData functions the underlying SQL is:
SELECT [Drive Package ID], [Drive Nomenclature], [Product Line ID],
[Unit Size], [Base Costs], [CFM HP Coefficent A0],
[CFM HP Coefficent A1], [CFM HP Coefficent A2],
[CFM equation motor HP], [Ext Static Pressure k
Coefficients],
[HP Max], [RPM Max], [RPM Min], [CFM equation RPM]
FROM [Drive Package]
The second used n FillMaxMins and GetMaxMins functions the underlying SQL is:
SELECT MAX([HP Max]) AS MaxHPMax,
MIN([RPM Min]) AS MinRPMMin,
MAX([RPM Max]) AS MaxRPMMax
FROM [Drive Package]
WHERE (([Product Line ID] = ProductLineID) AND ([Unit Size] = UnitSize));
Not there is no Join here these are just simple Queries on a simple table.
On the form, I have placed the following
productDataSet, drivePackegsBindingSource, and drive_PackageTableAdapter
I execute the following statement to fill the drive_PackageTableAdapter.
this.drive_PackageTableAdapter.Fill(this.productDataSet.Drive_Package);
I have only one question?
Given a value for ProductLineID and UnitSize what is the code to execute
either the FillMaxMins or GetMaxMins and what is the code to bet the values
in MaxHPMax, MinRPMMin, and MaxRPMMax?
I do not want to display this data I need the data in a variables to use in
code.
The reference you gave me does not make sense because I do not see where I
am using data views.
Thank you,
--
Mike Reed
"Cor Ligthert [MVP]" wrote:
Michael,.
Do you mean that you want selective use some columns from a datatable.
Your text is so long and contains so many elements which I can not place in
connection with the problem that it confuses at least me.
If the first sentence is your question than the answer can be this.
Dataview.totable(overloaded)
http://msdn2.microsoft.com/en-us/library/h2b6ehaa.aspx
Be aware that the result is than not a typed dataset from format 1.x or 2.0
because those are closed classes that assume that you do your column
selections for grids using the complex data controls. This is in fact a very
strange to use method and as often said by others in this newsgroup "a not
needed possibility".
If you want to do it with your flexgrid, why than not contact ComponentOne?
Cor
"Michael D. Reed" <chaskamn@xxxxxxxxxxxxx> schreef in bericht
news:C6AB7ABB-4C32-470A-9F65-DB2B3D7AD680@xxxxxxxxxxxxxxxx
Let me explain father:
The first I had add a table adaptor to an existing dataset call
productDataSet.xsd (using the graphical editor). This adaptor looks at a
table in an Access database connected to the dataset. When added a query
was
added that filled the complete table. The dataset, table-adaptor, and
associated binding-source are placed on a form (a MDI form, this should
not
make any difference); the table is filled when the form is loaded.
I then added the two queries shown in the original message. The first
query
returns a 5 column table with anywhere from between 0 and 5 rows; each
column
has an aliases to provide column headers. The second query returns 3
derived
columns with an aliases and returns one row. These both only return one
table and are simple queries on a simple table.
The question is:
How do i use the columns and aliases in the queries and only those
columns?
What seems to be returned is the complete underlying table columns and the
rows requested.
I assumed that the dataset is a typed data set, so I should be able to see
the columns in the IntelliSense list in the code editor, which I do not.
In
addition, they are not to be found in the Autos or Local windows when a
set a
brake point after executing the code shown in the original message.
On the first query, I have worked it out so I can use it with the flex
grid
form ComponentOne. I am use the flex grid because of some unique features
I
wanted.
The real problem is the second query:
I want the max and min to use in code. It looks like the only way I can
use
them is assuming the number of columns in the original table and taking
the
next three in a generic ItemArray. This is very poor programming
techniques
and tightly couples the database to the program, which I do not want.
Does this clarify what I want?
Thank you for your help.
--
Mike Reed
"Michael D. Reed" wrote:
I have a data set called "ProductDataSet.xsd" that include several tables
one
called [Drive Packages] with 14 columns and several rows of data. The
table
adaptor attached to this is a table adapter called "Drive Package
TableAdapter". To this table adapter I have added several queries:
One called list Data
SELECT [Drive Package ID], [Drive Nomenclature] AS Drive,
[HP Max] AS HP, [RPM Max] AS [Max RPM],
[RPM Min] AS [Min RPM]
FROM [Drive Package]
WHERE ([Product Line ID] = ProductLineID) AND ([Unit Size] =
UnitSize)
ORDER BY [Drive Nomenclature]
The two procedures are called FillListData and GetByListdata
When I excite the following statement
DataTable ListData =
this.drive_PackageTableAdapter.GetListData(ProductLineID, UnitSize);
The columns I have aliased above are now where to be seen. For this
quarry
I did not need them explicitly because I bound them to a C1 flex grid.
Although, I did have to make five columns in the right order and names.
Note
I the correct amount of rows for the where clause.
The second one Max Mins
SELECT MAX([HP Max]) AS MaxHPMax, MIN([RPM Min]) AS MinRPMMin,
MAX([RPM Max]) AS MaxRPMMax
FROM [Drive Package]
WHERE (([Product Line ID] = ProductLineID) AND ([Unit Size] =
UnitSize));
The two procedures are called FillMaxMins and GetMaxMins.
Again exciting
DataTable dataMaxMins = this.drive_PackageTableAdapter.GetMaxMins(2,
"086");
The aliases are no where to be seen. This one returns only one record
and
it did. So I tried:
object[] MaxMins = new object[3];
MaxMins = this.drive_PackageTableAdapter.GetMaxMins(2,
"086").Rows[0].ItemArray;
And I can see the data I want but it is tacken on the end of an array of
14
items. One for each column in the orignal table and the there ones
above.
The question is how do I get the coliums in the quary and only the colums
in
the quary? These are not complacte quaries and if I can not use the
dataset
for these what good is it.
--
Mike Reed
- Follow-Ups:
- Re: Using queries in a table adaptor?
- From: Cor Ligthert [MVP]
- Re: Using queries in a table adaptor?
- References:
- RE: Using queries in a table adaptor?
- From: Michael D. Reed
- Re: Using queries in a table adaptor?
- From: Cor Ligthert [MVP]
- RE: Using queries in a table adaptor?
- Prev by Date: Retrieving primary key of newly added record
- Next by Date: refresh from DataGridView to bound DataSet
- Previous by thread: Re: Using queries in a table adaptor?
- Next by thread: Re: Using queries in a table adaptor?
- Index(es):
Relevant Pages
|
|