473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Combine 4 columns into 1

I'm back and please be warned I'm a total NEWBIE, and i've had success with my previous post so I would like to buy another vowel!

Now i have taken my csv file and imported to a DataTable, i've parsed out the rows and columns to match two colums in SQL. If the two fields match, i want to create a record on a SQL Table. The problem is, I have 4 fields in the CSV file that I would like to "Concatenate" (don't know the syntax for c#) the first 4 columns in the CSV file to one column on the SQL Table. I'd be happy if you can just guide me in the right direction, is there a concatenate or append syntax i should be looking at? I'm doing this for the invoiceNumber column.

code snippet:
Expand|Select|Wrap|Line Numbers
  1.             foreach (string csvRow in extractCsv)
  2.             {
  3.                try
  4.                {
  5.                   DataTable table = ConvertCSVtoDataTable();
  6.  
  7.  
  8.                   foreach (DataRow csvrow in table.Rows)
  9.                   {
  10.                      foreach (DataColumn col in table.Columns)
  11.                      {
  12.                         string colloCode = csvrow[15].ToString();
  13.                         string fiscalYear = csvrow[13].ToString();
  14.                         string invDate = csvrow[4].ToString();
  15.  
  16.                         foreach (DataRow row in colloCodeTable.Rows)
  17.                         {
  18.                            if (colloCode == row["collocationCode"].ToString() && fiscalYear == row["fiscalYear"].ToString())
  19.                            {
  20.                               //string expDesc = "";
  21.                               //if (expDesc == "")
  22.                               //{
  23.                               //   //mapExpenseDescription();
  24.                               //}
  25.  
  26.                               Expense newExpense = new Expense();
  27.                               newExpense.CollocationCodeID = new System.Data.SqlTypes.SqlGuid(row["collocationCodeID"].ToString());
  28.                               string accountCode = csvrow[18].ToString();
  29.                               //expenseDescription = csvFields[18].ToString();
  30.                               string invoiceDate = Convert.ToString(csvrow[4].ToString());
  31.                               string invoiceNumber =
  32.                               //               //     string ledgerCode = "0"
  33.                               //               // string processDate = filestring.
  34.                               //               // string transactionAmount = filestring.
  35.                               //               // string vendorName = filestring.
  36.                               //               // string 
  37.                               //               //newExpense.AccountCode = Convert.ToInt16(accountCode);
  38.  
  39.                               //               newExpense.Persist();
  40.                            }
  41.                         }
  42.                      }
  43.                   }
  44.                }
  45.  
  46.                catch { }
  47.             }
Sep 25 '09 #1
2 4970
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Sep 25 '09 #2
tlhintoq
3,525 Expert 2GB
string NewString = MyString1 + MyString2;
Sep 25 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: DBLWizard | last post by:
Howdy, I need to compine two columns (LastName, Firstname) with the comma. The only problem I have is the Firstname could be blank and in that case I don't want the "," appended to the last...
1
by: Lars E. | last post by:
Hi all. I am trying to combine data from 2 tables in one datagridview. I have tables: "Customer" and "CustomerContact". I want to display Customer information (displaying all fields in...
3
by: tshad | last post by:
I have about 10 functions that are identical except for one variable name that I am using in my "for" loop: for (ktr1=1;ktr1<=nhDataBean.projectCodeList.GetUpperBound(0);ktr1++) for...
1
by: zwieback89 | last post by:
Hi, I am still not able to get this working in a simple page. Please help me. I am badly stuck.... I am trying to view the contents of the Beverage Category. I have built it like a hierarchy...
1
by: dayhill | last post by:
I am trying to combine three columns (month, day, year) to make one date (month-day-year). Here is the intital inforation when I hit the SQL button in Microsoft Query ...
0
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined...
2
denny1824
by: denny1824 | last post by:
Hi everyone, Here is my problem. I have a Table Variable (I could easily turn it into a Temp Table instead) that will sometimes have rows that are identical except for one specific column. The...
1
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
8
by: vineetbindal | last post by:
Hi All. I have two Columns column1 and column2. i have to run a query with some value from colum1 depending on it will select result from coloumn2 and if that result is present in coloumn 1 it...
36
by: stateemk | last post by:
I have a db with a table that has many columns of info for various entities. In this table, there are three columns called, entity name, second entity name and third entity name. I need to combine...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.