Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

datatable in asp.net - merge

Posted on 2011-03-07
4
Medium Priority
?
467 Views
Last Modified: 2012-05-11
Is there a way to merge year, make and model columns to one column, year_make_model?


datatable_1

orderdate      year      make      model
03/07/2011      2003       honda      civic exc

after

orderdate       Year_make_model
0
Comment
Question by:VBdotnet2005
  • 2
4 Comments
 
LVL 3

Expert Comment

by:chrisrbloom
ID: 35062249
Dim stYear, stMake, stModel, stCombined as String

stYear = {get year from datatable}
stMake = {get make from datatable}
stModel = {get model from datatable}

stCombined = stYear + " " + stMake + " " + stModel
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35062265
HI,

Did you application allows you to do it from the data source?  I mean from your query, something like this (assuming you are using SQL Server)

Select OrderDate, Convert(varchar, Year) + '_' + Make + '_' + Model As Year_Make_Model
From yourtable

or you have to do it once the data is in memory?
0
 

Author Comment

by:VBdotnet2005
ID: 35063921
Once the data in memory
0
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 2000 total points
ID: 35064276
Hi,

After you populate you Datatable_1, you can add a Calculated column like this

datatable_1.Columns.Add("Year_Make_Model", GetType(System.String), "Year + ',' + Make + ',' + Model")

And after that you can read the value from the new merge column

        MsgBox(datatable_1.Rows(0)("Year_Make_Model"))
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 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