Hi,
I am writing on my blog after a very long long time and I logged in on my web site after several unsuccessful attempt. :)
Well I have just started studying Sharepoint. So this is not for the guru. It is just for the people who just started Sharepoint like me.
In this example I will write a console application, which will read some data from a comma separated file (.csv) and will insert that data into sharepoint list.
I created a custom list in MOSS and named it myData. This list has some columns which are given below:
FirstName, LastName, age.
I also made a .csv file which have some data.
Snapshot of the sharepoint list is given below. You can see that this list is empty.

Code of my class is given below. You can also find this class in attachment of this post.
Code is self explanatory and also commented.
here is the code:
3: static void Main(string[] args)
7: SPSecurity.RunWithElevatedPrivileges(delegate()
9: //OPEN THE REQUIRED WEB
new SPSite("http://qaiser-6tmdbbtq:40934");
11: SPWeb web = site.OpenWeb();
12: // REQUIRED LIST OF THE WEB
13: SPList lstNames = web.Lists["myData"];
15: StreamReader sr =
File.OpenText("C:\\Names.csv");
16: string Data = string.Empty;
17: //LOOP THROUGHT AL THE FILE
18: while (!sr.EndOfStream)
20: Data = sr.ReadLine();
21: if (Data.IndexOf(',') > 0)
24: string[] Columndata =
Data.Split(new char[] { ',' });
25: // DECLARE LIST ITEM FOR ADD
26: SPListItem item = lstNames.Items.Add();
27: // ASSIGN APPROPRITE VALUES FROM THE
// DATA
Columndata[0].ToString();
29: item["LastName"] =
Columndata[1].ToString();
Convert.ToInt32(Columndata[2].ToString());
31: // DATA WILL NOT BE INSERTED UNLESS YOU
// CALL UPDATE METHOD OF LIST ITEM.
33: ///item.Update was throwing an error
//which was saying that I dont have rights to insert
34: ///data into the list. So to make sure
//that my code runs with proper security I encapsulate
35:///all of my code into a delegate which you can see in the first line
/// of try body, which is
36:///SPSecurity.RunWithElevatedPrivileges(delegate()
48: Console.WriteLine(ex.ToString());
.
In next post I will do the same thing but insted of using sharepoint object model, I will use Sharepoint web services.
Sorry that I didn't explain things in detail as I am in hurry :)
Remember me in your prayers..