Hi, i'm a new vb user,
may i ask how to get the max value from the followin situation?
Dataset name: dataset11
Table name: Employee
Column name: StaffID
the syntax is???
txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.????????
THX!!! 10 17723
Hi Gene,
You can possibly use DataTable's Select method, but I am not sure it
supports aggregate functions like MAX(). If it doesn't, you should iterate
on all the rows in the DataTable and find out the maximum value in this
column.
To the best of my knowledge, the DataColumn class itself does not provide
such functionality so there is nothing that could replace the "???????"
placeholder in your example.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Gene" <eu*******@hotm ail.com> wrote in message
news:u5******** *****@TK2MSFTNG P09.phx.gbl... Hi, i'm a new vb user, may i ask how to get the max value from the followin situation?
Dataset name: dataset11 Table name: Employee Column name: StaffID
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.???????? THX!!!
thx!!!
I'll try on that
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> ???
news:eR******** ******@TK2MSFTN GP09.phx.gbl ???... Hi Gene,
You can possibly use DataTable's Select method, but I am not sure it supports aggregate functions like MAX(). If it doesn't, you should iterate on all the rows in the DataTable and find out the maximum value in this column.
To the best of my knowledge, the DataColumn class itself does not provide such functionality so there is nothing that could replace the "???????" placeholder in your example.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Gene" <eu*******@hotm ail.com> wrote in message news:u5******** *****@TK2MSFTNG P09.phx.gbl... Hi, i'm a new vb user, may i ask how to get the max value from the followin situation?
Dataset name: dataset11 Table name: Employee Column name: StaffID
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.???????? THX!!!
"Gene" <eu*******@hotm ail.com> wrote in message
news:u5******** *****@TK2MSFTNG P09.phx.gbl... Hi, i'm a new vb user, may i ask how to get the max value from the followin situation?
Dataset name: dataset11 Table name: Employee Column name: StaffID
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.????????
This question will be better answered by the ADO.NET group. However, I
*think* you can accomplish this two ways:
1) select an aggregate of the desired column in your actual SQL statement:
SELECT MAX( StaffID ) FROM [Employee]
GROUP BY {add your grouping fields here}
That will return 1 column, with the max values based on your grouping.
2) (not sure if this will work or not)Try using the MAX function in the
select query on the DataSet:
dataset11.Selec t("SELECT MAX(StaffID) FROM [EMPLOYEE]...")
This is the same as the previous method, but it all executes client side,
wich is much better in terms of server abuse. I think it returns either a
DataRowView, or a DataRow( ). If you are having problems with this method,
check the documentation on the DataSet.Select( ) method.
HTH,
Jeremy
Hi Gene,
I am curious, why do you not just use a dataview?
something as rough written
\\\
dv as new dataview(datase t11.employee)
dv.sort="StaffI dColumn, ASC"
txtMaxStaffId.t ext=dv(dv.count-1)("StaffID")
///
Cor the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.???????? THX!!!
Hi Jerymy dataset11.Selec t("SELECT MAX(StaffID) FROM [EMPLOYEE]...")
Which version from VB?
:-)) I did try something like this this this morning but could not find it
Cor
Thx, Jeremy
I have another question is how to do it using method?
I know sql statement,
I know how to use select * from table,
but how to use other functions like MAX in the sql statement using vb.net.
do you mind tell me more on this?
"Jeremy Cowles" <jeremy.cowle s[nosp@m]asifl.com> ???
news:6d******** ***********@twi ster.tampabay.r r.com ???... "Gene" <eu*******@hotm ail.com> wrote in message news:u5******** *****@TK2MSFTNG P09.phx.gbl... Hi, i'm a new vb user, may i ask how to get the max value from the followin situation?
Dataset name: dataset11 Table name: Employee Column name: StaffID
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.????????
This question will be better answered by the ADO.NET group. However, I *think* you can accomplish this two ways:
1) select an aggregate of the desired column in your actual SQL statement:
SELECT MAX( StaffID ) FROM [Employee] GROUP BY {add your grouping fields here}
That will return 1 column, with the max values based on your grouping.
2) (not sure if this will work or not)Try using the MAX function in the select query on the DataSet:
dataset11.Selec t("SELECT MAX(StaffID) FROM [EMPLOYEE]...")
This is the same as the previous method, but it all executes client side, wich is much better in terms of server abuse. I think it returns either a DataRowView, or a DataRow( ). If you are having problems with this method, check the documentation on the DataSet.Select( ) method.
HTH, Jeremy
it's method "1"
"Gene" <eu*******@hotm ail.com> ¦b¶l¥ó
news:uk******** ******@TK2MSFTN GP09.phx.gbl ¤¤¼¶¼g... Thx, Jeremy I have another question is how to do it using method? I know sql statement, I know how to use select * from table, but how to use other functions like MAX in the sql statement using vb.net. do you mind tell me more on this?
"Jeremy Cowles" <jeremy.cowle s[nosp@m]asifl.com> ??? news:6d******** ***********@twi ster.tampabay.r r.com ???... "Gene" <eu*******@hotm ail.com> wrote in message news:u5******** *****@TK2MSFTNG P09.phx.gbl... Hi, i'm a new vb user, may i ask how to get the max value from the followin situation?
Dataset name: dataset11 Table name: Employee Column name: StaffID
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.????????
This question will be better answered by the ADO.NET group. However, I *think* you can accomplish this two ways:
1) select an aggregate of the desired column in your actual SQL
statement: SELECT MAX( StaffID ) FROM [Employee] GROUP BY {add your grouping fields here}
That will return 1 column, with the max values based on your grouping.
2) (not sure if this will work or not)Try using the MAX function in the select query on the DataSet:
dataset11.Selec t("SELECT MAX(StaffID) FROM [EMPLOYEE]...")
This is the same as the previous method, but it all executes client
side, wich is much better in terms of server abuse. I think it returns either
a DataRowView, or a DataRow( ). If you are having problems with this
method, check the documentation on the DataSet.Select( ) method.
HTH, Jeremy
thx Cor,
it seems to be a good suggestion to use dataview,
but I have never use it,
I'll try it, THX!!!
"Cor" <no*@non.com> ¦b¶l¥ó news:%2******** ********@tk2msf tngp13.phx.gbl ¤¤¼¶
¼g... Hi Gene,
I am curious, why do you not just use a dataview?
something as rough written \\\ dv as new dataview(datase t11.employee) dv.sort="StaffI dColumn, ASC" txtMaxStaffId.t ext=dv(dv.count-1)("StaffID") ///
Cor
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.???????? THX!!!
Gene,
In addition to the other suggestions I find the easiest way is to use the
DataTable.Compu te function.
txtMaxStaffID.t ext = dataset11.Emplo yee.Compute("Ma x(StaffID)", Nothing)
The second parameter is a filter, incase you want to limit the rows that are
applied to the aggregate function.
David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press
covers the DataTable.Compu te function along with every thing else in
ADO.NET!
Hope this helps
Jay
"Gene" <eu*******@hotm ail.com> wrote in message
news:u5******** *****@TK2MSFTNG P09.phx.gbl... Hi, i'm a new vb user, may i ask how to get the max value from the followin situation?
Dataset name: dataset11 Table name: Employee Column name: StaffID
the syntax is??? txtMaxStaffID.t ext = dataset11.Emplo yee.StaffIDColu mn.???????? THX!!!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: G Kannan |
last post by:
Hey all!
I have written a perl script to retrieve information from a HTML Form
and insert the data into an Oracle database table. I am gettting the
the following error message:
"Use of uninitialized value in concatenation (.) at register.pl line
38, <STDIN> line 10."
The PERL code is as follows:
|
by: otto |
last post by:
i need to read a variable in a javascript and translate it to a form in
html
the javascript variable is:
<SCRIPT LANGUAGE='JavaScript'>RF2N('Total');</script>
and i need to put that variable as the value in this line
<input type="hidden" name="AMT" value="**">
|
by: Eric Chang |
last post by:
I was working on this simple form with radio boxes.
And when I click on one of the radio box, it tell me the value is
"undefined"
Why is that ? I did defined the value of each radio box:
<input type=radio name='Usetax' value='basic'
onClick='document.myform.amount.value=document.myform.Usetax.value'>
<input type=radio name='Usetax' value='no'
onClick='document.myform.amount.value=document.myform.Usetax.value'>
<input type=radio...
|
by: cwizard |
last post by:
I'm calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not an object... the
function is like so:
function calc_total()
{
var x,i,base,margin,total,newmargin,newtotal;
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
|
by: dmiller23462 |
last post by:
So here's my problem.....I need to set up different email
distributions based on which option in the following Select form has
been chosen....For instance if "Putaway" is chosen it needs to email
User1@here.whatever and User4@here.whatever but if "Loaded" is chosen
it needs to email User2@here.whatever and User3@here.whatever, etc,
etc...
I'm aware that the only thing that really needs to change is the
"Mail.AddAddress" line (at least...
| |
by: matthew_carver |
last post by:
Hello,
I have an ASP page that loops through a SQL Server 2000 table, then
downloads an Excel sheet the users can save, etc. Works fine, except, I
see that in one particular "comments" field the Excel sheet returns a
#VALUE! error in the cell when there is a large amount of text. I've
looked through the MSKB, MSDN and many ng posts to see if there is a
workaround or solution to this, including looking at the xlWorksheet
properties. Is...
|
by: dbuchanan |
last post by:
Hello,
Here is the error message;
----------------------------
Exception Message:
ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child
key values (5) to exist in the parent table.
----------------------------
|
by: tania |
last post by:
i have this table in my database:
CREATE TABLE FILM(
F_ID INT(5) NOT NULL AUTO_INCREMENT,
F_TITLE VARCHAR(40) NOT NULL,
DIRECTOR_FNAME VARCHAR(20) NOT NULL,
DIRECTOR_LNAME VARCHAR(20) NOT NULL,
TYPE VARCHAR(30) NOT NULL,
DURATION TIME ,
YEAR_RELEASE YEAR NOT NULL,
DESCRIPTION TEXT,
|
by: cbellew |
last post by:
Hi guys,
I have a problem with an option group and a two corresponding text boxes. When the user chooses an option value i want the text boxes to populate with text dependent on the choice made.
I have written an AfterUpdate procedure on the frame to try and assign the text to the value of the text box, but for some reason it does nothing...
Here is the code:
Private Sub Frame0_AfterUpdate()
If Frame0.Value = 1 Then
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |