2011-06-15 65 views
-1

國內需求,我們必須讓我們開發系統表單副本到WSS 3.0日曆列表 簡單的說,我知道需要使用ADO來更新[Alluserdata]這個表並且知道whitch tp_listId。如何將數據寫入現有Sharepoint 2007日曆列表

但是,更新,已經寫入數據庫之後,它不能出現在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 
+5

爲什麼你直接訪問,而不是使用SharePoint API的SharePoint數據庫,?!?這真是**糟糕**的想法。 – 2011-06-15 07:15:07

回答

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(); 
+0

謝謝Ryan.Our開發NB操作系統是Windows 7 64位,我嘗試安裝WSS 3.0 64 Bit.But我不能安裝這個,所以我打開iis和www服務。最後....我找不到[ WSS在Windows 7上] ... – 2011-06-16 09:00:01

+0

你需要問這是另一個問題(「如何開發wss在win 7 x64上」) - 這就是這個網站的工作原理。同時你不要忘記標記這個答案是正確的,如果你覺得它的幫助(點擊刻度)一個恐懼FAQ右上。 – Ryan 2011-06-16 11:42:59

相關問題