This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Generate a New UID for the DB in VB Code

Hello

When we Import new orders into PersonWantsOrg, we get a lot of errors because it is quite hard to define a unique column that is also unique for the data in the table.

The only unique column is UID_PersonWantsOrg as far as I know.

So to avoid such messages when importing data, I have a column UID_PersonWantsOrg in m CSV and I wanted to use a System function the generate a uinique Value.

In SQL we have newid(), but in VB I did not find such a function that I can use in the Data Importer column script.

Workaround that I have for now is:

' V1

 

Value = Connection.CreateSingle("PersonWantsOrg").GetValue("UID_PersonWantsOrg")

 

' V2

 

Value = CCC_GenNewUID()

''' <summary>

''' CCC_GenNewUID

''' </summary>

''' <returns></returns>

Public Function CCC_GenNewUID() As String

    Dim dbobj As ISingleDbObject = Connection.CreateSingle("PersonWantsOrg")

    Dim sNewUID As String = dbobj.GetValue("UID_PersonWantsOrg")

    dbobj.Discard()

    Return sNewUID

End Function

Is there a better method?

Parents Reply Children
No Data