Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Loading data to lists on SharePoint?

  Asked By: Keaton    Date: Sep 30    Category: Sharepoint    Views: 2657

I have been tasked with taking a list of data, maybe 60,000 records or
so, and loading them onto a list that has been defined already.

Originally my approach had been to go right into the database and
insert the data into the UserData table directly. I have been
rethinking this, as it seems this is not what Microsoft says you are
suppossed to do, and they really don't want you manipulating the data

So what do you think? What is the best way to get the data into a list?

I guess as an alternative, is there an available web part that can
directly read and update a sql server table?



8 Answers Found

Answer #1    Answered By: Jennifer Jones     Answered On: Sep 30

I've had luck using the SPListItemCollection and SPListItem classes to
get to the list  already created. Once I get my data  from the database
into a DataTable, I used the method below:
---------------Begin code--------------------
private SPSite siteCollection = new SPSite("http:\\myPortal");
siteCollection.AllowUnsafeUpdates = true;
private SPList srcList =
private SPListItemCollection listItems = srcList.Items;

public void UpdateEmployeeList(DataTable HRTable)
foreach (SPListItem listItem in listItems)
string empNumber = listItem["EmployeeNumber"].ToString();
DataRow dr = HRTable.Select("EmployeeNumber=" + empNumber)[0];

catch(Exception ex)
{ }

---------------End code--------------------

Answer #2    Answered By: Annie Norris     Answered On: Sep 30

Here is a VS 2005 program that I use to upload quotations into a
list. A web part accesses the list  and displays a random saying on
each refresh. Just something for fun, but it takes a text input and
builds a list with saying and author as the columns. It's somewhat
long but I don't know if the saying will fit until I build it.

Answer #3    Answered By: Chadd Hahn     Answered On: Sep 30

I wonder if I could cut and paste your code below into a ASP Page…do you think that would work?

Also, Can you post the Web Part that displays a random quote as well. I’ve been having difficulty getting the random display part….

Answer #4    Answered By: Cheryl Kelley     Answered On: Sep 30

I used your code into a small c# console app, and then modifying it... and it worked great! (On the test environment)

Unfortunately, when I went to production, and went to run it I got the following error... The knowledgebase articles referenced seemed kind of useless, but I tried that and had no luck.

Help! Any ideas? This is the error I was getting. I can post the code for my CS app, but it is pretty much a hacked up clone of Gord's code.

Answer #5    Answered By: Sharonda Mcfarland     Answered On: Sep 30

The error you got was:
"The knowledgebase articles referenced seemed kind of useless, but I
tried that and had no luck."

I've never seen that error before.

Answer #6    Answered By: Damon Garner     Answered On: Sep 30

No the error I got was in the snippet after the stars
Unhandled Exception:
Microsoft.SharePoint.SPException: Cannot connect to the configuration database.
For tips on troubleshooting this error, search for article 823287 in the
Microsoft Knowledge Base at http://support.microsoft.com . --->
System.Runtime.InteropServices.COMException (0x81070555): Cannot connect to the con
figuration database. For tips on troubleshooting this error, search for article
823287 in the Microsoft Knowledge Base at http://support.microsoft.com.


my comment was that when I researched KB 823287 and followed the steps they reccomended, it did nothing to help me, so I thought it was kind of useless for me in this situation. The reason for my post was to see if anyone had had the same type of trouble in running a console application on a sharepoint  server, running into a permissions error.

Answer #7    Answered By: Jaime Weaver     Answered On: Sep 30

My reply was tongue-in-cheek, I just didn't see the error message (I see
it now).

Looks like the console app is not passing sufficient credentials or more
likely, the credentials being passed are not the ones that you think are
being passed. Perhaps you can debug it and see what is actually being
used. Sorry I don't have anything cleaver to suggest.

Answer #8    Answered By: Anibal Baird     Answered On: Sep 30

You will need to write a custom program using the SharePoint API. It
should not take more than an hour or so. I would probably write it as a
console application.

Didn't find what you were looking for? Find more on Loading data to lists on SharePoint? Or get search suggestion and latest updates.