读书人

想通过C#窗体把dataview的数据更新到

发布时间: 2013-01-04 10:04:14 作者: rapoo

想通过C#窗体,把dataview的数据更新到SharePoint的List Item上
如题,
但可是我连普通的更新也做不到

我贴出我的代码,麻烦看看,他一运行,连我的断点都不停留。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using Egensource.IntelliOffice.UI;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;
using System.Text.RegularExpressions;
using System.Web;

namespace testList
{
class Program
{
static void Main(string[] args)
{

using (SPSite site = new SPSite("疑问1"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["testC#"];
//允许修改list

site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;
//填充list表单
SPListItem item = list.Items.Add();
string getday = DateTime.Today.ToShortDateString();
string itemTitle = "test";
item["Title"] = itemTitle;
item["a"] = "5";

item["b"] = "Dep";
item.Update();
}

}


输出的提示是
在 System.IO.FileNotFoundException 中第一次偶然出现的“System.Windows.Forms.dll”类型的异常
线程 0xda0 已退出,返回值为 0 (0x0)。
程序“[3264] LinkToMoss.vshost.exe: 托管”已退出,返回值为 -532459699 (0xe0434f4d)。


SPSite(里面应该List的地址),还是放什么?
现在是运行不成功,想看断点都看不到!
求帮忙!!!!


[解决办法]
1楼的问题 不知你什么意思。
继续我3楼回答
testC# 是你的列表名字吗,在网站首页吗?
SPList list = web.Lists["testC#"];

-------------------------------------------------
site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;
//填充list表单
SPListItem item = list.Items.Add();
string itemTitle = "test";
item["Title"] = itemTitle;
item["a"] = "5";

item["b"] = "Dep";
item.Update();
试试 , 你是在什么里做的。

[解决办法]
你用的是SharePoint 2010还是2007?
如果是2010 你貌似用的是Server Model的API,只能在SharePoint Server上面运行哦。
如果不是在SharePoint server上运行,建议用Client Model,具体用法请参考:
http://www.codeproject.com/Articles/268193/SharePoint-2010-Client-Object-Model-Part-1
http://www.codeproject.com/Articles/268196/SharePoint-2010-Client-Object-Model-Part-2

然后你的应用程序.Net版本只能是3.5的。因为SharePoint 2010 是不支持4.0 或4.5 的

读书人网 >行业软件

热点推荐