473,480 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Querying a dataset

JC
I have created a data adapter (CheckVacationHrsDataAdapter1) and generated a dataset (CheckHrsVacDataSet1) in the form designer. What I would like to do is query this dataset, find the sum of TotalVacationHrs per EmployeeID, and put this sum in a text box. How do I load my dataset at runtime in order to query it? Here is my query...please help

"SELECT SUM(TotalVacationHrs
FROM PYCheckHistor
WHERE (Employee = '" & EmployeeID & "')

My data adapter is mapped to the table PYCheckHistory
Nov 20 '05 #1
8 4180
Hi JC,

I think this is what you are looking for

http://msdn.microsoft.com/library/de...mputetopic.asp

I hope it was the answer?

Cor
Nov 20 '05 #2
Hi JC,

VacHrsThisYr.Text =
CheckHrsVacDataSet1.Tables("PYCheckHistory").Compu te("Sum(TotalVacationHrs)"
, "Employee = 'ARBUCKLEP'").toString

With other names of course, does work for me

No name problems or case sensitive problems (This kind of statements is case
sensetive)

Cor
Nov 20 '05 #3
Hi JC,

I tried it with this sample, can you try it also, the value is 1200

I hope it is with you the same?

Cor
\\\
Dim dt As New DataTable
Dim dc As New DataColumn("OHM")
dc.DataType = GetType(System.Int32)
Dim dd As New DataColumn("OHH")
dd.DataType = GetType(System.Int32)
dt.Columns.Add(dc)
dt.Columns.Add(dd)
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
dt.Rows(i)(0) = 100
dt.Rows(i)(1) = 1
Next
Me.TextBox1.Text = dt.Compute("Sum(OHM)", _
"OHH = 1").ToString
///
Nov 20 '05 #4
JC
Cor, could it be that my datatable is not populated with the dataset??
Nov 20 '05 #5
JC

That you can test with by instance

messagebox.show(CheckHrsVacDataSet1.Tables("PYChec kHistory").rows.count.tost
ring)

Cor
Nov 20 '05 #6
Hi JC,

Have a look at this,
http://msdn.microsoft.com/library/de...ClassTopic.asp

When you use OleDb just change SQL in OleDb

I hope this helps?

Cor
Nov 20 '05 #7
Hi JC,

If you have created a dataadapter using the designer and generated the
dataset with that, than you need only that fill with the right dataadapter
and datasetname (strong one)

I give it with a non strongly typed dataset also, however than your program
becomes fast a mesh. This should be enough when you made all with the
designer.

dap1.Fill(das1) ' the names you where using
VacHrsThisYr.Text = das1.Compute("Sum(TotalVacationHrs)", "Employee =
'ARBUCKLEP'").ToString

However when you first want to try from the outside

Dim cnn1 As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;
Data Source=J:\TCMW\Database\TCMW.mdb")

Dim dap1 As New OleDb.OleDbDataAdapter("SELECT Employee, CheckDate,
TotalVacationHrs from PYCheckHistory", cnn1)
Dim das1 As New DataSet
dap1.Fill(das1)
MessageBox.ShowRows.Count.ToString)

VacHrsThisYr.Text =(das1.Tables(0).Compute("Sum(TotalVacationHrs)",
"Employee = 'ARBUCKLEP'").ToString

I thought that this should work ( I typed it in here in this message and
mostly I make than typos)

Cor
Nov 20 '05 #8
Hi JC,

Do you mean something as?

VacHrsThisYr.Text = myTable.Compute("Sum(TotalVacationHrs)", "((EMPLOYEE =
'" & "EmployeeID') AND (CheckDate >" & " 'DateOfHire'))").ToString

Cor
Nov 20 '05 #9

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

Similar topics

17
1223
by: Dan Koster | last post by:
I have three weeks of history for all user accounts stored in a DataSet (dsAccountsHistory). I want to be able to narrow that data down to one specific user, at runtime, without having to make...
3
2286
by: C. Hughes | last post by:
I have a simple application that uses an XML file to store it's data. That means I don't have a seperate database. In order to read the data I created a DataSet that reads my XML file with the...
2
2436
by: Abhishek Srivastava | last post by:
Hello All, Suppose if I have a SQL query like select p.ID, p.NAME, p.UNIT_PRICE, o.QUANTITY from PRODUCT p ORDERS o where p.ID = X AND P.ID = O.ID Here one product can have many orders....
3
1568
by: MDB | last post by:
I'd normally Google for a question like this, and hope to snag a few examples along with the answer, but this time I can't see to get the keywords specific enough. Or I'd ask coworkers, but...
1
2309
by: Michel Moreno | last post by:
Hi everybody, i would like to query the Index Catalog, for a site, as describe in the article: http://support.microsoft.com/default.aspx?scid=kb;en-us;820105 But i'm having an error, I don't know...
6
316
by: Fred | last post by:
I want to use a dataset so that I can obtain data from a number of sources and put it into one table. Using dataadaptors this seems to work well. Now I have a table (Forecast) in the dataset with...
1
965
by: sharmaajay | last post by:
hi all, i want to know whether we can make a dataextract function in global page(global.asax) though a query and.. then for each individual .aspx page can we query tht dataset instead of creating...
5
3672
by: sql_er | last post by:
Guys, I have an XML file which is 233MB in size. It was created by loading 6 tables from an sql server database into a dataset object and then writing out the contents from this dataset into an...
2
1438
by: Peter Savas | last post by:
I am new to programming in C#, but have been a VB coder for 16 years, and am facing a problem which I could use some help with: I have an XML file which I am reading into a C# DataSet object with...
2
1464
by: Steven Cheng [MSFT] | last post by:
Hi Cj, I also noticed that the "Act" variable here seems hasn't been declared(or declared anywhere else?). I've try building the same code and got the same result and the "Operator '+' cannot be...
0
6904
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...
0
7037
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
6895
tracyyun
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...
0
5326
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,...
1
4770
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2992
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
1296
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
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
176
bsmnconsultancy
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...

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.