Da bin ich wieder.
Ich habe doch beschlossen die Daten die ich über ODBC ca. 2 mal die Woche einspiele mit den schon vorhandenen im Notes zu vergleichen und nur die neuen Daten zu Importieren und ggf. alte Daten zu aktuallisieren.
Anbei lege ich mein script mit dem ich die Daten Importiere.
Hat jemand eine Lösung bzw. ein Script, den ich anpassen könnte, um mein Vorhaben zu realisieren ? Ich kann mir vorstellen, dass es in der Richtung schon was gibt.
Danke im Voraus.
Sub Click(Source As Button)
REM Notes Objects Declarations
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
REM Miscellaneous module variables
Dim msg As String
Dim FieldCount As Integer
Dim Status As Integer
REM MS Access Database declarations
Const adbFileName = "bever" ' This is the DSN Name as registered in ODBC
Const adbTableName = "KostenstellenSelektionTbl" ' This is a table in the northwind database
REM Notes Database declarations
Const ndbViewName = "vtranskostenstellen" ' This is an existing View in the target database
Const ndbFormName = "mtranskostenstellen" ' This is an existing Form in the target database
REM Instantiate the major Notes objects
Set db = session.CurrentDatabase
Set view = db.GetView( ndbViewName )
REM Connect to the MS Access Database. Throw an error if it fails
status = con.ConnectTo( adbFileName )
If Not con.IsConnected Then
Messagebox "Could not connect to " & adbFileName & " database -- Did you register the ODBC Data Source???",, "Error"
Exit Sub
End If
If con.GetError <> DBstsSUCCESS Then
Messagebox con.GetExtendedErrorMessage,, "Connection Error - " & con.GetError & " " & con.GetErrorMessage
Exit Sub
End If
Print "Connected to " & adbFileName & " database" ' Update the Notes Client Status Bar if we're okay
REM If we got this far, we must be connected, so just for grins, let's show the user all the fields in this table.
REM Note: "fields" has not been declared, so it will be a Variant Array -- that's what we want
fields = con.ListFields( adbTableName )
msg = adbTableName & " contains the following fields:" & Chr(10)
For FieldCount = Lbound( fields ) To Ubound( fields )
msg = msg & Chr(10) & fields( FieldCount )
Next
REM Okay, let's display the Field List to the User...
Messagebox msg,, "Fields from the " & adbFileName & " database"
REM We made it this far, so let's setup the SQL Query. Throw an error if it fails
Set qry.Connection = con
Set result.Query = qry
qry.SQL = "SELECT * FROM " & adbTableName ' Grab all of the fields (columns) from the specified table
If qry.GetError <> DBstsSUCCESS Then
Messagebox qry.GetExtendedErrorMessage,, "Query Error" & qry.GetError & " " & qry.GetErrorMessage
Exit Sub
End If
REM Update the Notes Client Status Bar
Print "Reading" & adbFileName & " database" ' Update the Notes Client Status Bar if we're okay
REM Must be okay -- Get the Data
result.Execute
result.CacheLimit = DB_NONE
REM See if we have data. If so, loop through the ResultSet. If not, throw an error
If result.IsResultSetAvailable Then
Do
result.NextRow
REM Create a Notes Document, assign values, save the document. Do it until we're done.
Set doc = db.CreateDocument ' Create a new Notes Document for this record
doc.Form = ndbFormName
REM Okay -- Let's get serious -- We'll use the MS Access Database field (Column)
REM names for the field names in the Notes Documents
doc.Name = result.GetValue( "Name" )
doc.Rolle = result.GetValue( "Rolle" )
doc.DimElementBez = result.GetValue( "DimElementBez" )
doc.Unit = result.GetValue( "Unit" )
doc.Replikation = result.GetValue( "Replikation" )
doc.KTelefon = result.GetValue( "Telefon" )
doc.KStatus = result.GetValue( "Status" )
doc.KEMail = result.GetValue( "EMail" )
doc.Recht = result.GetValue( "Recht" )
doc.Personal = result.GetValue( "Personal" )
doc.Sach = result.GetValue( "Sach" )
Call doc.save( True, False )
Loop Until result.IsEndOfData
REM We're done, so let's clean up the mess we've made and bail out
result.Close( DB_CLOSE )
Print "Finished" ' Update the Notes Client Status Bar if we're okay
Else
REM If we got here, it means there was no data in the table, so throw an error (Informational)
Messagebox "No data retrieved for " & adbTableName & " table", MB_ICONINFORMATION, "No data"
Print "DOH!!!!! Got no data -- Bummer!!!!" ' Update the Notes Client Status Bar if we're NOT okay
Exit Sub
End If
REM Give up the ODBC Connection like a good little boy
con.Disconnect
REM Update the view so the new documents will show up without having to press the F9 key
Call view.Refresh
Call ws.ViewRefresh
End Subb
End Sub
P.S. Es muss ein Kompleter Datensatz als Einheit gesehen werden d. H. es müssen alle 11 Felder zusammen vergliechen werden !!!