Das Notes Forum
Domino 9 und frühere Versionen => ND7: Entwicklung => Thema gestartet von: Big768 am 07.05.09 - 11:01:12
-
Liebe Noteskolleginnen und - kollegen,
gestern habe ich eine schönen Agenten geschrieben, der mir Daten über ODBC aus einer Access-Datenbank einliest. Dies funktionierte, Dank MSAccessReader, auch wunderbar. :)
Wenn ich heute Ändererungen an diesem Agenten oder an einem zweiten Agenten mache die sich sehr ähneln, erhalte ich immer die Fehlermeldung:
Not a sub or function name: DISCONNECT >:(
Dabei habe ich gar nichts geändert.
Kann es eventuell daran liegen, dass ich gestern den letzten Agenten abbrechen musste, weil er zu lange dauerte?
Hat jemand einen Tip?
Vielen Dank im voraus.
Johann
-
Woher kommt den die Funktion "DISCONNECT"?, vielleicht ein option declare hinzugefügt?
-
Ja, ich habe ein zusätzliches Feld eingefügt aber auch wieder entfernt. Trotzdem erscheint der Fehler noch. ???
Und warum in dem anderen Agenten den ich gar nicht geändert habe?
-
Füg mal in dem Agent ein:
ein!
-
Danke für den Tip.
Nun lautet die Fehlermeldung:
Not a sub or function name: Execute ???
-
Poste mal den Code hier rein ;) und markiere die Zeile mit dem Fehler :)
-
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 ***rot***
Dim qry As New ODBCQuery ***rot***
Dim result As New ODBCResultSet ***rot***
REM Miscellaneous module variables
Dim msg As String
Dim FieldCount As Integer
Dim Status As Integer
REM MS Access Database declarations
Const adbFileName = "FrankiermaschineA" ' This is the DSN Name as registered in ODBC
Const adbTableName = "CostAccounts" ' This is a table in the northwind database
REM Notes Database declarations
Const ndbViewName = "CA" ' This is an existing View in the target database
Const ndbFormName = "CostAccounts" ' 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 ) ***rot***
If Not con.IsConnected Then ***rot***
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.CAID = result.GetValue( "ID" )
doc.CAReference = result.GetValue( "CostAccountReference" )
doc.CAName = result.GetValue( "CostAccountName" )
doc.CACreation = result.GetValue( "DateTimeCreation" )
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
-
Ich habe mich mit der Fehlermeldung vertan:
Sie lautet nun: Variable not declared: GET VALUE
-
Ist das ODBC-LSX überhaupt eingebunden?
Bernhard
-
Wenn ich die *** rot **** richtig sehe, ist doch klar, warum ein .con.Disconnect den Fehler wirft; wenn schon con nicht instantiiert ist.
Du solltest mal prüfen, ob deine ODBC LSX richtig eingebunden ist ...
-
Ist natürlich die Frage wie der Agent überhaupt jemals laufen konnte ;)
Für den Fall das Du nicht weisst welche Codezeile noch fehlt:
Uselsx "NLSXODBC"
-
und ich bin mir sicher, dass ich diese Zeile gestern nicht brauchte.
Vielen, vielen Dank.
-
Okey, wenn du das wieder hinbekommst dann melde dich mal ;D
-
evtl hattes du sie mal drin.
Ich hatte mal selbes Phänomän mit: useLsx "javacon*"
Wenn das ein Agent mal gemacht hat, gehen auch alle anderen, solange der client nicht neu gestartet wurde. (An sowas sucht man dann teilweise lange, da ja das Problem irgendwann nicht mehr reproduzierbar war ;D )
Gruß
Roland