PDA

View Full Version : CSV(Comma Separated Value) Problem



Yusuf
04-06-2012, 03:28 PM
I have a form where to user inputs all the date. Now I need to save all the data in the form on a server(fictitious). How to do that?
After recording it in the database, I'll need to import it in a database. How achieve this?

alykins
04-06-2012, 09:04 PM
assuming they entered it into textbox1


string contents = textbox1.Text;
string[] splitS = contents.Split(',');


example console code...


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DaysDemo
{
class _DaysDemo
{
static void Main(string[] args)
{
string demo = "demo,meod,toodle,cat";
string[] splits = demo.Split(',');
foreach (string s in splits)
{
Console.WriteLine(s);
}
Console.ReadLine();
}
}
}


Edit: oh and as follow up to you other Q's... after it's split convert it to the appropriate datatype and pass it to database