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

How to generate UID for any table?

Hi,

We are trying to insert data in table using script for which we need to generate UID as well as XObjectKey. I tried searching for OOTB system scripts if we can reuse it and generate UID but could not find it. Can you please help? Thank you.

Parents Reply
  • Hi Markus,

    Here is the code

    Public Function testscript() As String

    Dim ConnectionString As String = Connection.GetSingleProperty("DialogDatabase", "ConnectionString", "")
    Dim con As New SqlConnection
    con.ConnectionString = ConnectionString


    Dim Querypeset As String = "Insert Into Eset (Ident_Eset,DisplayName,Description) Values('ABC','ABC','description')"

    Dim cmdpeset As New SqlCommand(Querypeset, con)

    con.Open()
    cmdpeset.ExecuteNonQuery()

    con.Close


    Return "done"
    End Function

    and the error message

    Exception has been thrown by the target of an invocation.
    Cannot insert the value NULL into column 'UID_ESet', table 'IDSVCDB.dbo.ESet'; column does not allow nulls. INSERT fails.
    The statement has been terminated.

Children