473,794 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combine 4 columns into 1

3 New Member
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 "Concatenat e" (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 4996
tlhintoq
3,525 Recognized Expert Specialist
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 Recognized Expert Specialist
string NewString = MyString1 + MyString2;
Sep 25 '09 #3

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

Similar topics

10
1986
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 name. This data is coming out of a Sql Server data base. I am currently using a DataReader and simply binding it to a data grid to display the information.
1
3429
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 customer and some fields from customercontact) in a datagridview. I am not using sql so innerjoin is not possible.... The relation between the tables are: Customer.c-custno = CustomerContact.cc-custno.
3
1318
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 (ktr1=1;ktr1<=nhDataBean.shiftCodeList.GetUpperBound(0);ktr1++) for (ktr1=1;ktr1<=nhDataBean.statusCodeList.GetUpperBound(0);ktr1++) How can I change the "nhDataBean.xxx.GetUpperBound(0)" so that I can use only one function?
1
2504
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 in the form of styled <UL> tags. Please assist me in combining the 2 pages into one page. I would extremely grateful. My code is:
1
2742
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 UtilityMaster.mDateAutoInst1, UtilityMaster.dDateAutoInst1, UtilityMaster.yDateAutoInst1 Here is what I modified it to: UtilityMaster.mDateAutoInst1+'-'+UtilityMaster.dDateAutoInst1+'-'+UtilityMaster.yDateAutoInst1 When I hit OK, I get the following error: ...
0
3479
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 one which creates a pivot table and sorts it into different fromats. Here is the code, can any body help? Sub Update_Land_Actuals() On Error Resume Next If InputBox("Enter password to continue", "Centex Homes") <> "***" Then Exit Sub...
2
5723
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 column is of nvarchar. When the rest of the columns for those rows are identical, I want to combine all of the values of that column into a single nvarchar with a delimiter in between each value. Then combine the rows where all of the other columns are...
1
3418
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 below. My problem is if I don’t use the WHERE clause in my script below, the script can query up to 3 records with the same “LoanNo” due to the fact that there can be up to 3 “TypeCodes” in each Table (Borrower, Co-Borrower 1 and Co-Borrower 2...
8
3979
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 will again select something from coloum2 again if that new result is present in coloum 1 it will select something from colum2 . i have to combine all this in one column without repeating values. something like. Column1 Column2 Column3 2100 ...
36
3846
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 all three columns into one drop box so a search can be done. Once the correct entity name is found, I need to be able to select it and bring up a form with all the data for that entity. For example, say there is an entity that has a name change so...
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.