Solved

diffrent or sum tow colum in datagridview

Posted on 2011-02-26
5
297 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 50 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

690 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