Jeff,
UniObjects has the error property for each method. It is a stack and you
have to query it after each method otherwise you get unpredictable error
messages.
What this means in practice is with Richard example:
Private rsFile As UniFile ' file handle to open file
rsFile.RecordId = rsCurrentKey
rsFile.Read
if rsFile.error = UVE_RNF then' for Record Not Found
'Do something
Elseif rsFile.error = UVE_NoError then 'Read was successful and you have now
'the record
Debug.Print rsFile.Record.Field(1).stringvalue
End if
You have the file UVOAIF.txt that comes with the UniObjects installation.
Reference this in the project, to get the error equates, otherwise you get
error number like '35001' which doesn't mean much. It is a good idea to read
through the error equates and know the 10 most common.
'To create a new record:
Dim Item as New UniDynArray
Item.Field(1).stringvalue = "Bla"
Item.subvalue(3,2,1).stringvalue = "blabla"
rsFile.record = Item
rsFile.recordID = rsCurrentKey
rsFile.Write
'This is a method, so you have to check the error property. Do this
'religiously If rsFile.error <> UVE_NoError then
MsgBox "Error " & rsFile.error & " happened"
End if
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard Taylor
Sent: Thursday, March 02, 2006 10:12 AM
To: [EMAIL PROTECTED]; [email protected]
Subject: RE: [U2] UniObject file write in VB
I wrote an application that used uniobjects with a Universe backend.
Here are some code fragments. You read a file using a UniFile object as
follows. If the Record member is NOTHING then the record was not found
Private rsFile As UniFile ' file handle to open file
rsFile.RecordId = rsCurrentKey
rsFile.Read
If rsFile.Record Is Nothing Then
....
Here is some record writing logic Note you have to set the record key too
DIM WorkingRecord as UniDynArray
....add data to WorkingRecord
rsFile.RecordId = rsCurrentKey
rsFile.Record = WorkingRecord
rsFile.Write
If rsFile.Error <> 0 Or rsFile.Status = -3 Then
...
If you have any ON ERROR RESUME NEXT lines comment it out so you can see
if you are getting a runtime error
Not you need to be create the Dynamic array either using the line above
that defines WorkingRecord or use
SET WorkingRecord as New UniDynArray
Rich Taylor | Senior Programmer/Analyst| VERTIS
250 W. Pratt Street | Baltimore, MD 21201
P 410.361.8688 | F 410.528.0319
[EMAIL PROTECTED] | http://www.vertisinc.com
Vertis is the premier provider of targeted advertising, media, and
marketing services that drive consumers to marketers more effectively.
"The more they complicate the plumbing
the easier it is to stop up the drain"
- Montgomery Scott NCC-1701
> I am creating a VB project that accesses multivalues. How do I create a
> new record? Here is my approach.
> OpenFile
> ReadRecord
> Record Nothing ? (this is not nothing with new record) or
> Record.Count=0?
> No - get MV count +1, update field values and write -- this works
> Yes - create a new record UniDynArray (VB won't let me do this),
> insert values, set file.record=new rec, write -- this does nothing. No
> new record.
>
> Any suggestions? The documentation on VB uniobjects is real weak.
>
> Thanks,
>
> Jeff
> -------
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/