Error Trapping - OO4O and Wizards(Archived)

I am unable to trap run time errors. The "On Error" statements does not seems to work. I've tried both "GOTO label" and "Resume Next". But when the user/password is wrong or the user have no access to the table. VB trapped the error and never pass the control to my "IF" statement. For example:
Dim sesOra As New OraSessionClass
Dim dbOra As OraDatabase
Dim rsOraLC As OraDynaset
On Error Resume Next
Set dbOra = sesOra.OpenDatabase(xDBserver, xUserId & "/" & xPassword, ORADB_ORAMODE)
If Err.Number > 0 Then
Msgbox Err.Description,vbCritical
Exit Sub
End If
Me.Language_Prim.RowSource = ""
Me.Language_Prim.RowSource = ""
Set rsOraLC = dbOra.CreateDynaset("SELECT * FROM dbo.Language_Control", ORADYN_READONLY)
If Err.Number > 0 Then
Msgbox Err.Description,vbCritical
Exit Sub
End If
rsOraLC.MoveFirst
Do While Not rsOraLC.EOF
If Me.Language_Prim.RowSource = "" Then
Me.Language_Prim.RowSource = rsOraLC.Fields("TX_language").Value & ";" & rsOraLC.Fields("CD_Language").Value
Else
Me.Language_Prim.RowSource = Me.Language_Prim.RowSource & ";" & rsOraLC.Fields("TX_language").Value & ";" & rsOraLC.Fields("CD_Language").Value
End If
rsOraLC.MoveNext
Loop

Prior to calling and after calling the CreateDynaset method use the LastServerErr functionality as such...
dbOra.LastServerErrReset 'Clear Error on Oracle OLE Object
Set rsOraLC = dbOra.CreateDynaset("SELECT * FROM dbo.Language_Control", ORADYN_READONLY)
'Force Error Handling for Oracle
If Not (dbOra.LastServerErr = 0) Then
Err.Raise 440, "Oracle Automation (OO4O)", _
"( " & dbOra.LastServerErr & " ) - " & _
dbOra.LastServerErrText & vbLf & _
"Position: " & dbOra.LastServerErrPos
End If
Do note, there are three diferent ways OO4O traps errors that may not be seen by the hosting langauge. The two most common being LastServerErr on both the Session and Database objects. The least know is the LastErrorText property of the OraParamArray object.
Zane E 

I tried the code but it doesn't seems to work. Let me clarify my problem. It is with "OpenDatabase". When I entered the wrong password. VB trapped the error and display the standard error pop-up panel showing "Runtime Error 440:" with the appropriate ORACLE error message. I would like to trap it and prompt the user to re-enter the userid/password. I'm just wondering if there's a set of command to tell VB to not trap the OO4O errors and let the application handle it?
Regards,
Jason Fenixdy
P.S. I'm using VB under Access 2000. 

Do the On Error Resume Next as you were and test the LastServerErr property for the value of '1017' (ORA-01017) after your OpenDatabase call.
Good Luck
Zane E 

The problem was setting in MS Access. Somehow on my machine the Error Trapping 'Option' is set to Trap all error. Everything worked like a charm after I changed it to 'Trap Only Unhandled Error'.

Related

Syncing with eVB...strange.

Hi,
I am trying to sync from within my eVB app.
I am using the following code:
---------------------------------------
Private Sub cmdSync_Click()
On Error Resume Next
Dim sync As MSYNC.sync
Dim syncOpt As MSYNC.SyncOption
Set sync = CreateObject("MSync.Sync")
Set syncOpt = CreateObject("MSync.SyncOption")
syncOpt.Load
syncOpt.username = "dg"
syncOpt.password = "abcd"
syncOpt.transportParam = "10.0.2.101;"
syncOpt.Save
MsgBox "save"
sync.setOptionObject (syncOpt)
MsgBox "setoptionobject"
sync.doSync
MsgBox "dosync"
If Err.Number <> 0 Then
MsgBox Err.Number & "-" & Err.Description
Else
MsgBox "Operation Completed Successfully", vbInformation
End If
---------------------------------------------
Problem is that the sync.doSync does not to execute. I don't recieve any errors, the process just stops when hitting sync.doSync.
All the other variables fire and if I comment out sync.doSync I end up making it through the entire procedure.
I haven't really coded much in the past, maybe it is something obvious I'm doing wrong. Though I pretty much copied this code from the transport tutorial.
Does anyone have any ideas as to what could be going on.
Thanks.
Darren 
Just noticed that:
syncOpt.transportParam = "10.0.2.101;"
should read:
syncOpt.transportParam = "server=10.0.2.101;"
This did not fix my issue. If anyone has any input, it is appreciated. 
Please see the link below...
9iLite mSync.sync error (3012) 
Thanks for the link.
I tried your code, but I still get the same thing. When it gets to the doSync, nothing happens. I don't get an error like you were. My app does not close down either.
It is almost looks like I'm suppling the wrong user/pass/server info, thus the sync doesn't work.
But, I can do the sync using msync.exe with the same info (though I am having issues with the 2-way sync, but that is another thread).
Like I said before, I don't really code...is there anyway to put some error checking around the doSync so I can try see what is going on when the routine calls it.
Thanks.
Darren 
Hi,
There is a bug in Oracle Lite 9i where the sync COM object will not work. I had the same problem as you and I filed an iTAR with Oracle and they created a bug report 3074671. The bug is only if you are using the mdk on a windows machine (I'm using win 2k sp3) and the Mobile Server is on a Unix or Linix (I'm using HP UX 11) machine. Supposedly this will be fixed with version 5.0.2.7 of 9i Lite, which is supposed to come out on August 7th, this Thursday, but I'm only going on what Oracle told me, I haven't tested it to see if it works or not.
BTW I was getting the -3012 error when I was using syncOption, when I took that code out and just used the default values I wasn't getting that error any more....another error that I hope is fixed with the newer version of 9i Lite.
hope this helps... 
Thanks Shaun.
Thing is I'm using win2000 Pro all around. It is really strange, as it is just the sync.doSync that doesn't seem to be working.
Darren 
Well,
I upgraded to 5.0.2.6 and the doSync now magically works as does the 2-way syncing. 
Good to hear that it's working now :)
I just have to wait until I get 5.0.2.7 and hope that it fixes my problem... 
I've read your posts and I still have the problem.
I'm running the last patch which is 5.0.2.9.0 and the 9 Database, with eVB 3.0.
I can just sync when I start the app and not during the app or whenever I want. I thought these were standard functionalities.
Can someone help?
Here's the code:
Public Sub OraSyncInit()
'1 - criar op��es e sync
Set SyncOpt = CreateObject("MSync.SyncOption")
Set Sync = CreateObject("MSync.Sync")
' 2-carregar sync info
'MsgBox "SyncOpt.Load"
SyncOpt.Load
'MsgBox "SyncOpt.username = " & SyncOpt.username
'MsgBox "SyncOpt.password= " & SyncOpt.PASSWORD
MsgBox "SyncOpt.syncParam= " & SyncOpt.SyncParam
'MsgBox "SyncOpt.transportType= " & SyncOpt.transportType
'MsgBox "SyncOpt.transportParam= " & SyncOpt.TransportParam
' SyncOpt.SyncParam = "reset;fullrefresh;" ' N�O FUNCIONA! BUG!
SyncOpt.TransportParam = "128.254.20.4;"
' SyncOpt.username = "sysadm"
' SyncOpt.PASSWORD = "sysadm"
' '3-gravar op��es
'MsgBox "SyncOpt.save"
' SyncOpt.save
'4-associar op��es ao object de sync
Sync.setOptionObject SyncOpt
End Sub
Public Function OraSync()
'Sincronizar
' On Error Resume Next
WaitCursor True
Sync.DoSync
WaitCursor False
' On Error GoTo 0
End Function 
Jorge,
I believe you have to make sure you close and then open your database before and after syncing. Don't forget to reload any record sets that may be required.
We haven't gotten to the point yet where we have done any testing on this though.
for example:
Private Sub cmdSync_Click()
On Error Resume Next
Dim sync As MSYNC.sync
Dim syncOpt As MSYNC.SyncOption
'Code for running the sync process
MsgBox "This operation takes about 2 minutes"
db.Close
<rest of code>
sync.doSync
db.Open "dbname", "user", "pass"
If Err.Number <> 0 Then
MsgBox Err.Number & "-" & Err.Description
Else
MsgBox "Operation Completed Successfully", vbInformation, "Sync Successful"
End If
End Sub
I think Darren's right with having to close the DB before synchronisation then re-open it again afterwards, I've seen the Java APIs require this as well.
Simon.

Create Folders using API on remote gadget server

I'm trying to create folders in the catalog using the api but I'm not having any luck.
Here's a piece of code I'm using:
Dim ptscThisFolderDim intFolderID, newFolderNamenewFolderName = getFolderName(FolderID)response.write "newFolderName = " & newFolderName & "<br>"Set ptscThisFolder = ptfoldThisParentFolder.Interfaces("IPTServerContext")intFolderID = ptfoldThisParentFolder.Interfaces("IPTServerContext").ObjectIDresponse.write "folder name = " & ptfoldThisParentFolder.Path & "<br>"response.write "Folder ID = " & intFolderID & "<br>"
Set ptObjectBeingCreatedOrEdited = ptCatalog.CreateFolder(intFolderID)ptObjectBeingCreatedOrEdited.Name = newFolderNameresponse.write "err = " & err.number & " - " & err.description & "<br>" Set ptscObject = ptObjectBeingCreatedOrEdited.Interfaces("IPTServerContext")Set GetACL = ptscObject.ACLresponse.write "getacl err = " & err.number & " - " & err.description & "<br>"
No errors are being reported and nothing is getting created in the catalog.
Any ideas????
Mike
I should have mentioned. I'm trying this on a PT 4.5 SP2 portal
I think you need
ptscObject.Store
Ahhhhh, sweet success!!!!!!
Thanks
Mike
You need to call the store method of the IPTServerContext interface, that will commit the changes to the DB.
thanks,
Craig
now can you do this with VB in an exe (that takes paramters) and allows you to create and submit cards as well?
I've been working on trying to created cards with parameters. But have been unsuccessful sofar. I've followed many paths to accomplish this but I've only been able to create a blank card without the right properties. I'm going to try the datasource.importdocument method once I get the propertybag format figured out, and see if that will work.
Mike
Creating cards is rather complex; it entails a number of objects, like Data Sources, Document Types, etc. Have you thought about using the EDK functionality to submit a new document? It is much more straight forward, but may not have the flexibility that you need.
In 4x, you can use the submithelper form the catbrwos library:
here is a complete example. just keep in mind that you the remote api running on the server running the app. If you want it don in asp, take a look at creatOrEditCard.asp:
Private Sub Form_Load()
Dim ptSession
'reference the plumtree.dll librarySet ptSession = CreateObject("PLUMTREE.InProcSession")ptSession.Connect 1, "" 'username or ID and password Dim ptCatalog As IPTCatalogSet ptCatalog = ptSession.Catalog ' Create the submit helperDim cbSubmitHelper As PCBSubmitHelper 'refrence catbrows.dll to get the submit helperSet cbSubmitHelper = CreateObject("CatBrows.PCBSubmitHelper") ' Give the session to the helpercbSubmitHelper.ptSession = ptSession ' Give the data source IDcbSubmitHelper.lDataSourceID = 102 ' I picked the 102, which is the standard filesystem datasource ' Create an array of the folders IDs to submit toDim aFolders(0)aFolders(0) = 230 ' ***** Enter the ID of the folder that you want to use here ' Give the folders arraycbSubmitHelper.vtFoldersForSubmission = aFolders ' Tell the helper not to upload (1 ==> upload and works for file only)cbSubmitHelper.UploadDocument = 0 Dim strSource As StringstrSource = "C:\Plumtree\plumtree\test.txt" 'the path to the file you want to upload ' Set the path to the document we want to submitcbSubmitHelper.strSourceDoc = strSource '**** Enter the link to the web page or the UNC path if it is a file ' Set refresh info and expiration settings to the default valuesCall cbSubmitHelper.InitCardRefreshInfoCall cbSubmitHelper.StoreExpirationSettings 'import the cardCall cbSubmitHelper.ImportCard
Dim lCardID 'if you want the objectid of the card you just submittedlCardID = cbSubmitHelper.SaveCard()
'MsgBox lCardID'clean up
Set ptCatalog = NothingSet cbSubmitHelper = NothingSet ptSession = Nothing
End Sub
From what I've seen the EDK would be easier but for now I'm on a 4.5 portal. I went to an EDK class a couple of weeks ago and am really looking forward to getting into the Remote Client.
I've been looking at the createOrEditCard.asp extensivily. And initially tried the catbrows as done by PT. But the catbrows.dll is not installed on my remote gadget server. If I just copied the dll from a PT server and register it would it work??
In the case above, the Call cbSubmitHelper.ImportCard calls the store method.. you don't have to explicitly call it.
Registering the dll is not sufficient. you have to install the plumtree remote server to get the rest of the components.
This line:
Call cbSubmitHelper.ImportCard()
produces this error:
err = -2147467259 - Error in CPTFileProvider::Initialize, unable to impersonate user '**DatasourceServiceAccount**'. Error in CPTImpersonateNTUser::ImpersonateUser logging on as user '**DatasourceServiceAccount**': A required privilege is not held by the client. (process user needs additional NT priviliges) (522)
What privilege do I need to grant???
One of the following could be causing this error:
1. The file system datasource you're using runs as a user that has an invalid passowd.
2. The plumtree package (under COM+ packages) is running as a user that does not have (Act as part of the operating system) advanced right. Keep in mind that the COM+ user needs to impersonate the datasource user to get to the file you're submitting.
"Act as part of the operating system"

Problem using PvarTempNCx Temporary Variables

Hi All
Hoping someone can help me with the usage of the PvarTempNCx variables.
I have created a batch script in which I have read the status of the 'EnableChkIntersect' record from the tCtrlOption table into one of the above variables. I then need to evaluate this in two event scripts so that I can conditionally turn the setting on/off depending upon the FDM location that the batch is processing data for.
I have tried to call using RES.PvarTempNC1 consistently but it does not keep the value I set in the batch script in the other scripts. So I tried to decalre it publically but that doesn't work either.
Does anyone know a way to declare a variable in one script and use the value in subsequent scripts?
Any help greatly appreciated.
Stuart 
Hi Stuart,
as far as I could find out the PvarTempNCx variables are not kept in the Event-Scripts.
I'd suggest that you simply do the lookup in the Event-Scripts where you need them again.
I always try to avoid duplication of code by using VBScript classes.
But be aware that this is sometimes really hard to debug.
This way I created lots of functions I use over and over again ;-)
The only thing I have to copy everywhere is this Sub AddClass, but for this there will be no change ;-)
e.g. I have a custom general file with the content
Class CentralFunctions
Private useMapDate
     
     Private Sub Class_Initialize
     End Sub
     Private Sub Class_Terminate
     End Sub
Function checkIntersect()
'your code goes here
End Function
End Class
and then in the EventScript I have something like the following:
Sub BefExportToDat(strLoc, strCat, strPer, strTCat, strTPer, strFile)
     Dim cf
     AddClass(DW.Connection.pstrDirScripts & "\Custom\" & "CentralFunctions.uss")
     Set cf = New CentralFunctions
     
cf.CheckIntersect ' this calls your central function or sub
     Set cf = Nothing
End Sub
'==============================================================
Function AddClass(strClassFile)
Dim oFSO, oFile, strFile
Set oFSO = CreateObject ("Scripting.FileSystemObject")
'Check to see if the file to be loaded exists. If it does not, return an error
If Not oFSO.FileExists(strClassFile) Then
AddClass = Array("1", "The specified class file " _
& strClassFile & " does not exist")
Exit Function
End If
On Error Resume Next
Err.Clear
'OPen the file to be loaded. If the open fails, return an error.
Set oFile = oFSO.OpenTextFile(strClassFile, 1, False, -1)
If Err.Number <> 0 Then
AddClass = Array(Err.Number, _
"The specified class file " & strClassFile _
& " could not be opened for reading.")
Exit Function
End If
On Error GoTo 0
'The file object is created so read all of the file and ececute it globally to load the class for use
strFile = oFile.ReadAll
oFile.close
Set oFSO = Nothing
Set oFile = Nothing
On Error Resume Next
ExecuteGlobal strFile
On Error GoTo 0
AddClass = Array("0", "")
End Function 
Thanks for the reply!
Unfortunately you have passed the limit of my VB knowledge so I will run this by a colleague and see if we can progress it further.
Thought I would post back as well that I have managed to find a method that works to an extent for me. Instead of storing the 'EnableChkIntersect' status in a variable and passing it to different event scripts I have done the following instead:
1. Added code into my batch script before the batch processing begins to read the 'EnableChkIntersect' variable from the database
2. Added code into my batch script after the batch processing finishes to re-set the 'EnableChkIntersect' status to what it was before the batch ran (using my variable, as it is in a single script I no longer need to pass it between scripts)
3. Added code into the BefValidate event script that does some conditional checks (for whether it is a batch process and the location being processed) and sets the 'EnableChkIntersect' status according to the clients requirements.
Regards
Stuart

Returning a value from API.DataWindow.Utilities.mShellAndWait

I would like to use API.DataWindow.Utilities.mShellAndWait in an FDM event script, to run a batch script which should echo some values I require. For example:
Dim strParams
strParams = API.DataWindow.Utilities.mShellAndWait "\\<servername>\Folder1\Folder2\Params.bat",0
However, I am receiving the following error:
Error:
Error: Expected end of statement Script=BefLoad
If I comment out this line the error message goes away. Can anyone please point out my error and suggest how I can achieve this? Many thanks in advance. 
I believe my first error is that API.DataWindow.Utilities.mShellAndWait is a subroutine rather than a function, so it will return nothing.
Is there a way to obtain the output from a batch script similar to the above? 
mShellandWait is one of those FDM API items that I necessarily don't like nor see the value since it most likely just repacking existing functionality from the OS anyway.....
I would just use Wscript to get thsi done.
Const WshFinished = 1
Const WshFailed = 2
strCommand = "\\<servername>\Folder1\Folder2\Params.bat"  
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)
Select Case WshShellExec.Status
      Case WshFinished
               strOutput = WshShellExec.StdOut.ReadAll
      Case WshFailed
               strOutput = WshShellExec.StdErr.ReadAll
End Select
'Display output
If LCase(API.DataWindow.Connection.PstrClientType) = "workbench" Then
     MsgBox strOutput       
Else
     'Let the user know we are done
     RES.PlngActionType = 2
     RES.PstrActionValue = strOutput
     
End If 
Thank you for your response. In the end I opted for a different method, and kept the command within batch scripts, so that a value did not need to be returned to the FDM event script. However, the requirement may come up again in the future, and when it does I will be using your suggested solution. Thanks! 
Hi James,
would it be possible for you to share th method you used as i am trying to do the very same thing...
cheers

9iLite mSync.sync error (3012)

I am trying to sync my iPAQ with my mobile server from a vb program. But I can not use the syncOpt object. It closes my whole application with giving error (3012). I see the 3012 number for a while and then suddenly my program becomes terminated.
I tried to update "conscli" database in my program, but the funtions that I coded was not true or are not doing the same thing with mSync program, because I get errors when callaing doSync function of the mSync.Sync object after I update the conscli database(C$USERNAME, C$CLIENT_PREFERENCES tables).
Do you have any idea about this issue? 
We are using V5.0.2 with eVB on iPAQ 3650, 3765, TMobile PDA Phone, and Symbol 8100, and 2800 series scanners with no problmes.
Does th msync util in the \orace folder of the PDA work? 
Yes we made it work. You need MGP running on the Mobile Server although there is not any sentence in the documents that saying MGP is a must to be able to sync your client with mobile server.
I have the problem with msync library(com interface) in eVB. But I am still on the job...
PS: I am working with iPAQ 3850 and it is fine... 
At last I achived to sync via eVB program with using mSync.sync object(doSync function).
Below you can find the sample code...
------------------CODE-------------------
Dim objSync 'As MSYNC.sync
Dim syncOpt 'As MSYNC.SyncOption
On Error Resume Next
Set syncOpt = CreateObject("MSync.SyncOption")
Set objSync = CreateObject("MSync.Sync")
If Err.Number <> 0 Then
MsgBox Err.Number & "-" & Err.Description
HourOff
If IsObject(objSync) Then Set objSync = Nothing
If IsObject(syncOpt) Then Set syncOpt = Nothing
Exit Sub
End If
' Load last sync info
syncOpt.Load
' Change user name to our username
syncOpt.Username = gMSUserName
' Change password to our password
syncOpt.Password = gMSPassword
' Change password to our server name or address
syncOpt.transportParam = gMSServer
'finally we save this information in order to set the last user that did synchronization
'after this step "objSync.DoSync" method will use the abouve parameters because we saved them
syncOpt.save
Set syncOpt = Nothing
'IMPORTANT
'---------------
'---------------
'---------------
' We Do not use this object
' We do not Tell ISync to use this option
' objSync.setOptionObject syncOpt
'---------------
'---------------
'---------------
objSync.DoSync
If Err.Number <> 0 Then
MsgBox Err.Number & "-" & Err.Description
Else
MsgBox "Operation Completed Successfully", vbInformation
End If
If IsObject(objSync) Then Set objSync = Nothing------------------CODE-------------------

Categories

Resources