代码之家  ›  专栏  ›  技术社区  ›  Albert

将Lotus Notes数据库导入到Access/SQL中-那文档呢?

  •  1
  • Albert  · 技术社区  · 14 年前

    我有一些LotusNotes“数据库”,希望导入到Access或SQL中。

    我认为我已经完成了大部分步骤(安装notessql-odbc驱动程序,设置与Lotus DB的ODBC连接,将数据导入Access),但我无法确定如何处理所有文档,例如:Lotus DB中的Word文件、PDF文档、Excel工作簿。

    LotusNotes数据库中充满了它们。导入之后,我确实注意到Access中有一个名为“documents”的表,但我不知道如何处理它。我看到了LotusDB中每个文档的一行/记录,但它不像SQL那样,实际文件数据有一列。

    请告诉我如何实际使用从LotusDB中提取的文档。

    1 回复  |  直到 12 年前
        1
  •  2
  •   Ken Pespisa    14 年前

    最好的办法是从数据库中提取文档并将它们存储在文件共享中。这将给你最大的灵活性。要保留与原始Notes文档的关联,您可能需要将它们与文件名一起导出,或者将它们导出到文件夹中,其中文件夹名包含Access中关联记录的ID。或者至少确保记录包括文档的路径。

    我不相信你能通过notessql驱动程序拉入附件。

    下面是一个示例脚本,您可以将其放入代理中,从数据库中提取附件:(来自 http://www.notes411.com/dominosource/tips.nsf/0/4F1FF33C52F08D76802570C2003A2FD6!opendocument )

    Sub Initialize 
          Dim session As New NotesSession 
          Dim db As NotesDatabase 
          Dim collection As NotesDocumentCollection 
          Dim doc As NotesDocument 
          Set db = session.CurrentDatabase 
          Set collection = db.UnprocessedDocuments 
          Set doc = collection.GetFirstDocument() 
          While Not(doc Is Nothing) 
                Call extractMyAttachment( doc ) 
                Set doc = collection.GetNextDocument(doc) 
          Wend 
    End Sub 
    
    Function extractMyAttachment (doc) 
          Dim emb As Variant 
          Dim nid As String 
    
          nid = doc.NoteID 
    
          Dim rtitem As Variant 
    
          Set rtitem = doc.GetFirstItem( "Body" ) 
    
          Dim pathName As String, fileName As String, mydir As String, 
    newfilename As String 
          mydir = "Coda" 
          pathName$ = "P:\" & mydir 
    
          fileName$ = Dir$(pathName$, 16) 
    
          Dim boxType As Long, answer As Integer 
          boxType& = 36 
    
          If fileName$ = "" Then 
                answer% = Messagebox("Directory "& pathName$ &" does not exist, 
    would you like to create it ?", boxType&, "Create" & mydir & " on P:\ ?") 
                If answer% = 6 Then 
                      Mkdir pathname$ 
    
                      fileName$ = Dir$(pathName$, 16) 
    
                      If filename$ <> "" Then 
                            If ( rtitem.Type = RICHTEXT ) Then 
    
                                  Forall o In rtitem.EmbeddedObjects 
                                        If ( o.Type = EMBED_ATTACHMENT ) Then 
                                              newfilename$ = pathname$ & "\" & 
    o.source 
                                              Call o.ExtractFile (newfilename$ 
    ) 
                                        End If 
                                  End Forall 
    
                            End If 
                      End If 
                End If 
    
          Else 
                If ( rtitem.Type = RICHTEXT ) Then 
    
                      Forall o In rtitem.EmbeddedObjects 
                            If ( o.Type = EMBED_ATTACHMENT ) Then 
                                  newfilename$ = pathname$ & "\" & o.source 
                                  fileName$ = Dir$(NewFileName$, 0) 
                                  If fileName$ <> "" Then 
                                        answer% = Messagebox("File "& 
    NewFileName$ &" already exists, would you like to overwirite it ?", 
    boxType&, "Overwrite" & NewFileName$ & " ?") 
                                        If answer% = 6 Then 
                                              Call o.ExtractFile (newfilename$ 
    ) 
                                        End If 
                                  Else 
                                        Call o.ExtractFile (newfilename$ ) 
                                  End If 
    
                            End If 
                      End Forall 
    
                End If 
          End If 
    End Sub