Domino 9 und frühere Versionen > Entwicklung

Gemeinsame Felder und Script MSAccessReader

(1/2) > >>

Jörg:
Hi Jungs,

ich nutze folgendes Script um eine Access-DAtenbank in Notes einzulesen:
 
--- Code: ---Sandbox (MSAccessReader)
--- Ende Code ---

Ich habe nun alle Felder entsprechend angepasst und habe das ganze
mit dem Standard-Formular eingelesen.
Nun habe ich aber ein neues Formular erstellt und hier nur Gemeinsame
Felder verwendet.
Diese Felder haben die gleichen Bezeichnungen wie die im org. Formular.

Aber leider bekomme ich immer eine Meldung das die Felder nicht gefunden/gefüllt werden können.

Wer kann mir hier helfen??
Gruss Jörg

Glombi:
Kannst Du das mal näher erläutern! So versteht keiner was Du willst.

Ist das ein Script aus der Sandbox auf LDD oder wie soll man der verstehen  ???

Andreas

Jörg:
Das ist das Script welches ich zum einlesen verwende.


--- Code: ---Sub Click(Source As Button)
REM  MS Access Reader by Gary Roberts  08/30/2000   
REM  Copyright Gary Roberts, 2000  (e-mail:  groberts@carolina.rr.com)
REM
REM  Application Name:  MS Access Reader
REM  View Name:  Customers
REM  Action Name:  Read MS Access Database
REM
REM  Purpose:
REM  Read a Microsoft Access (MS Access) MDB file and create a Notes Document for
REM  each record in the MS Access Database.  The newly created documents will be
REM  displayed in the "By Company Name" view in THIS Notes Database.
REM
REM  IMPORTANT NOTES:
REM  You do NOT have to have MS Access installed on your PC to run this program.
REM  You DO have to have the Northwind.mdb file (comes with MS Access)
REM  You DO have to register Northwind.mdb as an ODBC Data Source (System)
REM  You DO have to have nlsxodbc.dll in your Notes directory (NOT the Data Directory)
REM  You DO have to have lsconst.lss in your Notes directory (NOT the Data Directory)
REM  You DO have to have lsxbeerr.lss in your Notes directory (NOT the Data Directory)
REM The ODBC LSX File is declared in the FORM's (Globals) (Options) section
REM  I used the fully qualified filename of the DLL in case yours isn't registered
REM  LotusScript and Error constants are "Included" in the FORM's (Globals) (Declarations) section
REM
REM  Change Log:
REM  ------------------------------------------------------------------------------------------------------
REM  08/30/2000  Gary Roberts    Placed into production
REM

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 = "northwind"  ' This is the DSN Name as registered in ODBC
Const adbTableName = "hotine"  ' This is a table in the northwind database

REM  Notes Database declarations
Const ndbViewName = "Simpati WUT gesamt"  ' This is an existing View in the target database
Const ndbFormName = "Customer"  ' 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

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.RegNr = result.GetValue( "RegNr" )
doc.Name = result.GetValue( "Name" )
doc.Straße =  result.GetValue( "Straße" )
doc.Land =  result.GetValue( "Land" )
doc.PLZ =  result.GetValue( "PLZ" )
doc.Ort =  result.GetValue( "Ort" )
doc.Anrede =  result.GetValue( "Anrede" )
doc.Name =  result.GetValue( "Name" )
doc.Version =  result.GetValue( "Version" )
doc.Kaufdatum =  result.GetValue( "Kaufdatum" )
doc.LetztesUpdate =  result.GetValue( "LetztesUpdate" )
doc.Lizenzen =  result.GetValue( "Lizenzen" )
doc.AuftrNr =  result.GetValue( "AuftrNr" )
doc.eMail =  result.GetValue( "eMail" )
doc.eMail2 =  result.GetValue( "eMail2" )
doc.LAN =  result.GetValue( "LAN" )
doc.Vertrag =  result.GetValue( "Vertrag" )
doc.Update128a =  result.GetValue( "Update128a" )
doc.Update204a =  result.GetValue( "Update204a" )
doc.Patch202rpt =  result.GetValue( "Patch202rpt" )
doc.Patch204menu =  result.GetValue( "Patch202menu" )
doc.Autoupdate =  result.GetValue( "Autoupdate" )
doc.LizGer01 =  result.GetValue( "LizGer01" )
doc.LizGer02 =  result.GetValue( "LizGer02" )
doc.LizGer03 =  result.GetValue( "LizGer03" )
doc.LizGer04 =  result.GetValue( "LizGer04" )
doc.LizGer05 =  result.GetValue( "LizGer05" )
doc.LizGer06 =  result.GetValue( "LizGer06" )
doc.LizGer07 =  result.GetValue( "LizGer07" )
doc.LizGer08 =  result.GetValue( "LizGer08" )
doc.LizGer09 =  result.GetValue( "LizGer09" )
doc.LizGer10 =  result.GetValue( "LizGer10" )
doc.LizGer11 =  result.GetValue( "LizGer11" )
doc.LizGer12 =  result.GetValue( "LizGer12" )
doc.LizGer13 =  result.GetValue( "LizGer13" )
doc.LizGer14 =  result.GetValue( "LizGer14" )
doc.LizGer15 =  result.GetValue( "LizGer15" )
doc.Update1 =  result.GetValue( "Update1" )
doc.Update2 =  result.GetValue( "Update2" )
doc.Update3 =  result.GetValue( "Update3" )
doc.Update4 =  result.GetValue( "Update4" )
doc.Update5 =  result.GetValue( "Update5" )
doc.Update6 =  result.GetValue( "Update6" )
doc.Update7 =  result.GetValue( "Update7" )
doc.Update8 =  result.GetValue( "Update8" )
doc.Update9 =  result.GetValue( "Update9" )
doc.Update10 =  result.GetValue( "Update10" )
doc.Bestellt =  result.GetValue( "Bestellt" )
doc.Abbestellt =  result.GetValue( "Abbestellt" )
doc.RegNr2 =  result.GetValue( "RegNr2" )
doc.Part11 =  result.GetValue( "Part11" )
doc.BarCode =  result.GetValue( "BarCode" )
doc.Sprache =  result.GetValue( "Sprache" )
doc.Bemerkung =  result.GetValue( "Bemerkung" )

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 Sub
--- Ende Code ---

Glombi:
Nun sind wir ja ein Stück weiter.
Wie heisst denn jetzt die Fehlermeldung genau und in welcher Zeile tritt diese auf?
Dazu ist es hilfreich, wenn Du den Debugger Step by step mitlaufen lässt.

Andreas

Jörg:
Also die Meldungen sind:

1.) COSTUMERS contains the following fields
2.) No Data retrieved for Costumers table

Der Debugger steht bei:
Dim section as new section

Gruss Jörg

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln