By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

Combine 4 columns into 1

P: 3
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
Share this Question
Share on Google+
2 Replies


tlhintoq
Expert 2.5K+
P: 3,525
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
Expert 2.5K+
P: 3,525
string NewString = MyString1 + MyString2;
Sep 25 '09 #3

Post your reply

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