我只是起一個類似的任務(讓我找到了你回答的問題)。我正在嘗試將我們的Sharepoint文檔庫複製到SQL數據庫中。它不直接從SQL打開你的文件,它使用一些C#代碼來設置一個作業,打開可能是你想要的共享點。
到目前爲止我發現了兩種方法: 一種方法是將您的數據從Sharepoint複製到Access中的鏈接列表中,然後使用OLEDB方法打開它。 這裏找到:C# Sync MS Access database to sql server
private static void BulkCopyAccessToSQLServer
(CommandType commandType, string sql, string destinationTable)
{
string connectionString = @"C:\Migration\Sharepoint Access SQL Batch Job\Database11.accdb";
using (DataTable dt = new DataTable())
{
string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Migration\Sharepoint Access SQL Batch Job\Database11.accdb;Jet OLEDB:Database Password=password";
//using (OleDbConnection conn = new OleDbConnection(Settings.Default.CurriculumConnectionString))
using (OleDbConnection conn = new OleDbConnection(ConnStr))
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(cmd))
{
cmd.CommandType = commandType;
cmd.Connection.Open();
adapter.SelectCommand.CommandTimeout = 240;
adapter.Fill(dt);
adapter.Dispose();
}
using (SqlConnection conn2 = new SqlConnection(Settings.Default.qlsdat_extensionsConnectionString))
using (SqlConnection conn2 = new SqlConnection(connectionString))
{
conn2.Open();
using (SqlBulkCopy copy = new SqlBulkCopy(conn2))
{
copy.DestinationTableName = destinationTable;
copy.BatchSize = 1000;
copy.BulkCopyTimeout = 240;
copy.WriteToServer(dt);
copy.NotifyAfter = 1000;
}
}
}
}
另一種是使用Microsoft.SharePoint程序庫並直接從C#打開您的SharePoint然後把它複製到你的SQL。 這裏找到:http://www.dotnetspark.com/kb/3573-fetching-lists-from-sharepoint-2010-site.aspx
using (SharePointclientObj.ClientContext ctx = new SharePointclientObj.ClientContext(clientContext))
{
//Get the site
SharePointclientObj.Web site = ctx.Web;
ctx.Load(site);
//Get Lists
ctx.Load(site.Lists);
//Query
ctx.ExecuteQuery();
//Fill List
foreach (SharePointclientObj.List list in site.Lists)
{
Console.WriteLine(list.Title);
}
}
來源
2014-02-24 10:14:25
JPK
6.5!?真?節哀順變。 – 2010-05-24 20:20:17
SharePoint只是一個ASP.NET應用程序。如果你可以在ASP.NET中完成,你可以在SharePoint中完成。 – 2010-05-25 11:18:06
任何人都可以幫助我嗎? – nalini 2010-06-09 17:33:07