473,497 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Displaying number of rows as a text (no datagrid)

2 New Member
Hello. I am trying to find information on how to display calculations on the screen using .Net. I am not using a data grid. What I'm trying to do is display how many rows in a database and then do something with that. So for example, in my SQL database I have 345 rows each with an employees info. On the last column is status. 1 = still working and 2 = not working here any more.

I would like to display.

Number of employees = 345
Number of employees who left = 125
Jun 12 '07 #1
4 1315
dip_developer
648 Recognized Expert Contributor
Hello. I am trying to find information on how to display calculations on the screen using .Net. I am not using a data grid. What I'm trying to do is display how many rows in a database and then do something with that. So for example, in my SQL database I have 345 rows each with an employees info. On the last column is status. 1 = still working and 2 = not working here any more.

I would like to display.

Number of employees = 345
Number of employees who left = 125
A simple SQL query
Select COUNT(*) FROM tblEmployee WHERE status='2' will give you the no of employees who left.
Jun 12 '07 #2
gurusshetty
11 New Member
Hello. I am trying to find information on how to display calculations on the screen using .Net. I am not using a data grid. What I'm trying to do is display how many rows in a database and then do something with that. So for example, in my SQL database I have 345 rows each with an employees info. On the last column is status. 1 = still working and 2 = not working here any more.

I would like to display.

Number of employees = 345
Number of employees who left = 125
Hi

lets take an eg. where dataset name is ds and datatable name is employees.

add following lines to your code.

//to find no. of employees

DataView dv = new DataView(ds.employees);
dv.RowFilter = "status = 1";
int iExist = ds.employees.rows.count;

//to find no. of left employees
dv.RowFilter = "status = 2";
int iLeft = ds.employees.rows.count;

Regards,

Guru
Jun 12 '07 #3
nateraaaa
663 Recognized Expert Contributor
A simple SQL query
Select COUNT(*) FROM tblEmployee WHERE status='2' will give you the no of employees who left.
All you need to do is run the query (stored procedure is preferred) above and then assign the result to a label control.

Nathan
Jun 12 '07 #4
sscoder
2 New Member
Great! I tried the SQL query and it works fine. Thank you for your help.

One last question. Is there a way to do the following?

SELECT COUNT(Status) AS Total FROM tblEmployee WHERE Status='2' AND Status = '4'

Also, someone mentioned adding this to store procedure. How can I add both query in there? so for example.

Alter Procedure dbo.Status
@Status int
As
SELECT COUNT(*) FROM tblEmployee WHERE Status='2'
AND
SELECT COUNT(Status) AS Total FROM tblEmployee WHERE Status='2' AND Status = '4'
and also add the other count above.
Jun 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2760
by: Paul M | last post by:
Hi there, i hope someone can help me out here.. I have a input screen where i want the user to enter text in 2 different languages, english and macedonian. How is it possible to make the...
1
3257
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
1
1353
by: Asha | last post by:
grettings, i have been searching the web for articles on how to add new rows to datagrid... most of it does postback. do anyone here know of a good article which uses javascript to add new rows...
5
2718
by: Alfredo Barrientos | last post by:
Hi, Is it possible editing all rows in datagrid?, i mean all fields are enabled to edit?, and update all values in just one click? Thanks, Alfredo Barrientos
2
2367
by: Karl | last post by:
Hi there, Need help, thanks first. In a winform datagrid, if I find the data with some error, I want to hight the row. It could be multiple rows. But Datagrid.Select() only allows one row. How...
2
9746
by: Shailja | last post by:
Can anyone tell me how to count no of rows into DataGrid at runtime after entering data into it?
1
9313
by: sharadadutt1981 | last post by:
hi all, I was trying to fetch even or odd number rows from database. currently i am usying DB2 ver 8.0. any one can help me out.
1
1822
by: clickingwires | last post by:
How do you consecutively number rows in an aggregate query?
4
1216
by: selvamariappan | last post by:
Hi all , how to display various color for rows in datagrid in vb.net 2005, Not a Alternate colors, Thanks and regards selvamariappan.c
0
1217
by: mahendra dubey | last post by:
Hi There I am using Datagrid control provided by wpftoolkit in wpf.I have set ItemsSource property of datagrid.Now Problem is that rows of datagrid takes only the space needed to display,...
0
7160
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
7196
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...
1
6878
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...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
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 ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.