如何将数据写入现有的Sharepoint 2007日历列表

时间:2011-06-15 06:19:26

标签: sharepoint sharepoint-2007

国内需求,我们必须让我们的开发系统复制到WSS 3.0 Calendar列表 简单地说,我知道需要使用ADO更新[Alluserdata]这个表并且还知道whitch tp_listId。

但是,更新后,已写入数据库,它无法出现在Sharepoint页面中 我做错了什么? ps:怀疑tp_size字段相关,但不确定....

 Public Sub Pm_woToSharePoint(ByVal PM_WO_MAIN_VIEWRow As PM_WO_MAIN_VIEW)
     Try
         Dim cdataobj As New cDataACCESS
         Dim dt_Prolist As Data.DataTable
         Dim selectString As String


        selectString = "select top 1 * from AllUserData where   tp_listId='4C0516DB-B090-4740-A0F0-B99E6DC31C0C' order by tp_id desc"
         dt_Prolist = cdataobj.sqlDt(selectString, "SharepointConnectionString")
         Dim CalenderListRow As Data.DataRow = dt_Prolist.NewRow
         Dim CalenderListRow2 As Data.DataRow = dt_Prolist.Rows(0)
         With CalenderListRow2
             CalenderListRow.Item("tp_ID") = .Item("tp_id") + 1
             CalenderListRow.Item("tp_ListId") = .Item("tp_ListId")
             CalenderListRow.Item("tp_SiteId") = .Item("tp_SiteId")
             ' CalenderListRow.Item("tp_RowOrdinal") = 0
             CalenderListRow.Item("tp_Version") = 1
             CalenderListRow.Item("tp_Author") = 96
             CalenderListRow.Item("tp_Editor") = 96
             CalenderListRow.Item("tp_Modified") = Now
             CalenderListRow.Item("tp_Created") = Now
             CalenderListRow.Item("tp_Ordering") = DBNull.Value
             CalenderListRow.Item("tp_ThreadIndex") = DBNull.Value
             ' CalenderListRow.Item("tp_HasAttachment") = 0
             'CalenderListRow.Item("tp_ModerationStatus") = 0
             CalenderListRow.Item("tp_IsCurrent") = 1
             CalenderListRow.Item("tp_ItemOrder") = 100 * CalenderListRow.Item("tp_ID")
             CalenderListRow.Item("tp_InstanceID") = DBNull.Value
             '  CalenderListRow.Item("tp_GUID") = 4
             ' CalenderListRow.Item("tp_CopySource") = DBNull.Value
             'CalenderListRow.Item("tp_HasCopyDestinations") = DBNull.Value
             CalenderListRow.Item("tp_AuditFlags") = DBNull.Value
             CalenderListRow.Item("tp_InheritAuditFlags") = DBNull.Value
             CalenderListRow.Item("tp_Size") = .Item("tp_Size")
             CalenderListRow.Item("tp_WorkflowVersion") = 1
             CalenderListRow.Item("tp_WorkflowInstanceID") = DBNull.Value
             CalenderListRow.Item("tp_DirName") = .Item("tp_DirName")
             CalenderListRow.Item("tp_LeafName") = CStr(CalenderListRow.Item("tp_ID")) & "_.000"
             CalenderListRow.Item("tp_DeleteTransactionId") = .Item("tp_DeleteTransactionId")
             CalenderListRow.Item("tp_ContentType") = .Item("tp_ContentType")
             CalenderListRow.Item("tp_ContentTypeId") = .Item("tp_ContentTypeId")
             CalenderListRow.Item("nvarchar1") = PM_WO_MAIN_VIEWRow.ITEM_NAME & " " & PM_WO_MAIN_VIEWRow.ITEM_VALUE
             CalenderListRow.Item("nvarchar3") = PM_WO_MAIN_VIEWRow.ST_NAME_CHT
             CalenderListRow.Item("ntext2") = "機台:" & PM_WO_MAIN_VIEWRow.MS_NAME_CHT & " 生產人員:" & PM_WO_MAIN_VIEWRow.ProductPerson
             CalenderListRow.Item("datetime1") = DateAdd(DateInterval.Hour, -8, CType(PM_WO_MAIN_VIEWRow.START_TIME, DateTime))
             CalenderListRow.Item("datetime2") = DateAdd(DateInterval.Hour, -8, CType(PM_WO_MAIN_VIEWRow.END_TIME, DateTime))
             CalenderListRow.Item("int1") = 0
             '  CalenderListRow.Item("int2") = .Item("int2")
             CalenderListRow.Item("bit1") = 0
             CalenderListRow.Item("bit2") = 0
             CalenderListRow.Item("bit3") = 0
             CalenderListRow.Item("tp_Level") = 1
             CalenderListRow.Item("tp_IsCurrentVersion") = 1
             CalenderListRow.Item("tp_UIVersion") = 512
             CalenderListRow.Item("tp_CalculatedVersion") = 0
             CalenderListRow.Item("tp_UIVersionString") = "1.0"
             CalenderListRow.Item("tp_DraftOwnerId") = DBNull.Value
             CalenderListRow.Item("tp_UIVersionString") = DBNull.Value
             CalenderListRow.Item("tp_CheckoutUserId") = DBNull.Value
         End With

        dt_Prolist.Rows.Add(CalenderListRow)
         cdataobj.ExecSQL(dt_Prolist, selectString, "SharepointConnectionString")
     Catch ex As System.Exception
         Throw
     End Try
 End Sub

1 个答案:

答案 0 :(得分:6)

你在这里完全错误地追踪数据库,这是危险的unsupported

执行此类操作的正确方法是对象模型或Web服务(或2010年的客户端对象模型) - 请参阅herehere以开始使用。

这是2010年,但其相同的步骤2007 - How to add a event to a SharePoint 2010 Calendar

SPListItem newEvent = yourCalendar.Items.Add();

newEvent["Location"] = "This is location";
newEvent["Start Time"] = DateTime.Now;
newEvent["End Time"] = DateTime.Now.AddHours(1);
newEvent["Description"] = "Going for Meting";
newEvent["Title"] = "New Meting";
newEvent["fAllDayEvent"]  =  false;
newEvent["Category"] = "Meting";

//Create Event in the sharpoint.         
newEvent.Update();