unsupportedformatexception in Xojo

Trying to run a realbasic project in Xojo 2013 3.1
I get an unsupportedformatexception when setting a database file to a filename.
EMDB.databaseFile = EMdocs.Child(Fname)

The path is obviously ok, as it works in Real Studio 2011 4.2 every time.

More information would be useful. What is the contents of the Fname string?

Sure. I thought that the fact that it worked in Real Studio and not in Xojo would trigger a fast answer because it may have arisen before.

Fname = Macintosh HD:Users:antoinettemay:Documents:EMdocs:Wentz.adb
Wentz.adb is a REALSQLDatabase,

As mentioned, the project works fine in Real Studio.

OK I wasted your and my time. Sorry

EMDB.databaseFile = EMdocs.Child(Fname)
should have been
EMDB.databaseFile = GetFolderItem(Fname)
Since Fname already had EMDocs in it.
EMDocs = Macintosh HD:Users:antoinettemay:Documents:EMdocs
Fname = Macintosh HD:Users:antoinettemay:Documents:EMdocs:Wentz.adb

Still I ran the code EMDB.databaseFile = EMdocs.Child(Fname) a hundred times in Real Studio 2011 4.2 and it runs without a hitch. Xojo knows better.
So my question has changed to why that runs in Real Studio?

In Real Studio it defaulted to using the Absolute Path if you did not tell it what type of location you were giving it


EMDB.databaseFile = GetFolderItem(Fname, FolderItem. PathTypeAbsolute)

[quote=41938:@Charles Herndon]Still I ran the code EMDB.databaseFile = EMdocs.Child(Fname) a hundred times in Real Studio 2011 4.2 and it runs without a hitch. Xojo knows better.
So my question has changed to why that runs in Real Studio?[/quote]
I’m not sure why your code would ever have worked in Real Studio. Child only takes a file name as a parameter, not a path. However, as Norman notes, Xojo did introduce some changes to file paths. In particular for OS X, the native path (which uses “/” as the separator) is now used in most places. Older versions used AbsolutePath, which used “:” as separators.

Any update on this ?

I`m having same issue here on Xojo 2014R3.1

i have the following code :

  if contentSet.field("dateAcc").DateValue <> nil then
    superWin.MainWindowPatientAdminContainer.dateAccEditFIeld.text = contentSet.field("dateAcc").DateValue.frenchDate()
    superWin.MainWindowPatientAdminContainer.dateAccEditFIeld.text = ""
  end if

Where the part :
if contentSet.field(“dateAcc”).DateValue <> nil then

gives me the UnsupportedFormatException and if i press in the debug on that part i get ErrorNumber 0 and the rest are empty, it would be helpful to get more details and not just a 0, i don`t see any issue in that case . contentSet is a RecordSet and then i have the field where i get the value, which in my case a date.

I`ve saw some strange sessions on XOJO today, first time the software once run was not working at all, then i restart the xojo the app comes with errors and after a while it starts but crashes on that error and all without changing not even a “” of code, so very strange.

Can anybody clear my confusion on this issue please.

Thank you.

It would have been better to start a new conversation, as your issue is only tangentially related to the original. But that said, use

if contentSet.field(“dateAcc”).IsNull then

[quote=158167:@Tim Hare]It would have been better to start a new conversation, as your issue is only tangentially related to the original. But that said, use

if contentSet.field(“dateAcc”).IsNull then[/quote]
Well i just did that and it seems that IsNull does not work , so any ideas ?

Regarding the new conversation , as far as i see it is in the Database Section and it is related to the same Error, so i don`t see the need of creating a new conversation, better to have different problems that result to the same category and get the same error than search the whole forum for the same error, just my point , in case it makes you happy i can change it to a new conversation.

It’s a different situation though. There are all kinds of things that can throw an UnsupportedFormatException.

yes indeed , but in this case the issue was related to the db , in the same time it is strange that on the RealBasic on the same code everything is working perfect and in XOJO same code throws errors like that, and if i change
if contentSet.field(“dateAcc”).DateValue <> nil with if contentSet.field(“dateAcc”).StringValue <> “” it works but i dont know if its the right way, in the same time if the DateValue is not working anymore, i dont see the purpose of it in the code and it should be deprecated, i guess it is either a bug or a deprecated item that was not removed from the framework. in the recent project i had to replace that code in about 300 lines until now without knowing if its ok to doit or not because the old version is not working anymore .

The original case was related to the FolderItem, not the db. What is the contents of the column? Is it NULL? Or some other value?

Ah, ok, my bad then , me i see it as “unsupportedformatexception in Xojo Databases” so i did not checked all the conversation,

on my example it is a Recordset named contentSet and i`m checking the field dateAcc as a datevalue, but it seems that it gives that error, i was looking in the debugging window and i saw that that specific field is saved as a String field, and i set it asa a string , if i checked as <> than nil it give a error also so i put it <> than “” which theoretically is the same thing. so i guess it will do for now.

Thanks for the info.

But it’s not. NULL and and an empty string are generally not the same.

Which is why I asked about what is really in the column. That would be good to know in order to determine whether this is a framework bug or not.

Hello Tim, in the column is a date value and when i look in the debugger that is saved as a string so if i replace the .DateValue with .StringValue i can use the app but i have to replace the Nil with “” as well.

So it seems that there is an issue with that .DateValue thing, to prove that the data is what i have , you have the pictures below, so in some i have a date, in some i have date time value but the errors are the same.

Here is the date field from the table and it is the above code https://xojo.io/bf64cbf9f22a , and this is the second one where i have the date time value https://www.dropbox.com/s/5fjtmv6krsehl0z/S_dte_Field.tiff?dl=0

Peter i think you got it wrong, i said Nil not Null , and according to xojo docs , Nil means Used to determine if an object is nil (no value). in my case “” it`s same thing if i put it as a .StringValue.

From the docs it says also You can pass Nil for any of the string parameter types above (CString, PString, WString), but not for String. Passing Nil is not the same as passing the empty string, “”. Passing Nil means you want to pass a null pointer. Passing “” means you want to pass a non-null pointer to the representation of “” for the declared format. but in my case “” will do the job but unfortunately i prefer not to change a lot of code because of .DateValue.

Right. So the data in your table is not compatible with DateValue. The nil/null thing is a red herring. The values are not null, they are incorrectly formatted. So in this case, testing for <> “” is fine, but I’m not sure it really solves the problem. It just puts it off. If you only use these values as a string, you’re ok. You may have issues later if you want to get a date object out of them.

Nil means that a Xojo object has no value. It is not related in any way to the values in your database. Nil and Null are very different concepts.

Got that, so in my case i do have mostly 90% of the cases where i do have to get the date object out of those and to transform it in my date with subclassing the date. I will test it and let you know how it works, in the meantime what would be the correct date format ? in the xojo docs it states : Date 8 Stores year, month, and day values of a date in the format YYYY-MM-DD. The year value is four digits; the month and day values are two digits. , so in my sample case i do have 2014-11-11 , which is yyyy-mm-dd in that case is correct, than why i get the error ?

For the dte part i guess i should use a timestamp field instead of date .

2014-11-11 is correct for DateValue.
2014-11-11 00:00 is not.

[quote=159221:@Tim Hare]2014-11-11 is correct for DateValue.
2014-11-11 00:00 is not.[/quote]

I understood that, but if you look into my project the date that we are talking about is in the field dateAcc which is 2014-11-11 and it still throwing that error. so my question again is, where is the issue, in the DateValue part or in the framework ?