Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

diffrent or sum tow colum in datagridview

Posted on 2011-02-26
5
Medium Priority
?
299 Views
Last Modified: 2012-06-21
i have 4 colums
 1 - name   2- start date   3-end date  4- cost A  5-cost B

1-i want faind diffrent  date betwen c2 and c3 and in new colim name it tot_day
2- i want faind sum  c4 + c5
and c4-c5

i use visaul basic 2005
access
windose aplaction
0
Comment
Question by:ziayd2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 41

Expert Comment

by:graye
ID: 34989682
If you are using a DataTable to store your 5 existing columns, then you can just add a few extra columns to the DataTable.  These new columns will contain an "expression".   So, in your case, you'd add a new column for tot_day and set it's Expressio property to "[start date]-[end date]"

Take look at this article... it has some downloadable examples too.

http://www.emmet-gray.com/Articles/ADO_Expressions.htm
0
 

Author Comment

by:ziayd2009
ID: 34993386

i  use tihes cood  from example in article
 Dim dc As DataColumn
     
  LoadData()
        dc = New DataColumn("tt1")
        dc.DataType = GetType(Integer)
        dc.Expression = "tt1 + tt3"  ' two column types
        dataset3.Tables("tbl").Columns.Add(dc)
        Me.DataGridView1.DataSource = dataset3.Tables("tbl")

Open in new window

after tht it give me msg :-
Cannot set Expression property due to circular reference in the expression
why is not work
note:-
colum tt1 and tt2 is type of integr
0
 
LVL 41

Expert Comment

by:graye
ID: 34993449
Yeah, you can't call the new column by the name tt1 (in your example).   Call it something else... anything else.
0
 

Author Comment

by:ziayd2009
ID: 34993482
why ,
can  u explain more
what i can call colum ?
 can i call like tot1 or total
thank u
0
 
LVL 41

Accepted Solution

by:
graye earned 200 total points
ID: 34993882
Yeah, that'd do just fine...   the problem is that you can't create a new column using a name that already exists.  So, "total" would do just fine.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question