Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send data from sharepoint list to non-sharepoint sql db

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I have a basic understanding of how to get to the data in a given sharepoint list. What I'm not sure of is then, how to insert this data into a seperate database (ms sql). My goal is to have this process run every thirty minutes, query the sharepoint list for any new items, then insert them into a sql table.

Here's the code I have for getting at the list:
Code:
using (SPSite curSite = new SPSite("[URL unfurl="true"]http://zanett-spdev-rb"))[/URL] //[URL unfurl="true"]http://gps.technicolor.com[/URL]
            {
                using (SPWeb curWeb = curSite.OpenWeb()) 
                { 
                    //create our query
                    SPQuery curQry = new SPQuery();

                    //configure the query
                    curQry.Query= @"
                        <Query>
                          <Where>
                            <Gt>
                              <FieldRef Name='Created'/>
                              <Value Type='DateTime'>DateTime.Now.AddMinutes(-15);</Value> 
                            </Gt>
                          </Where>
                        </Query>
                        ";

                    //get our list
                    SPList curList = curWeb.Lists["Notifications"];

                    //get the collection of items in the list
                    SPListItemCollection curItems = curList.GetItems(curQry);

                    //enumerate the items in the list
                    foreach (SPListItem curItem in curItems);
	                
                    {
                    //insert into db here
                    }

                }
                curSite.RootWeb.Dispose(); 
            }

Any ideas on how to tackle the insert process?
 
you should just be able to use a standard insert statement into the sql database. if you are using vs2008, you can also look at linq to sql.

I would suggest posting a question in the C# forum for more info about doing a sql insert from visual studio.

carl
MCSD, MCTS:MOSS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top