datatable in - merge

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


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


orderdate       Year_make_model
Question by:VBdotnet2005
  • 2

Expert Comment

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
LVL 13

Expert Comment

ID: 35062265

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?

Author Comment

ID: 35063921
Once the data in memory
LVL 13

Accepted Solution

gamarrojgq earned 500 total points
ID: 35064276

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


Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now