Quantcast
Channel: aras PLM community
Viewing all articles
Browse latest Browse all 1103

Item added through SQL query is not accessible

$
0
0

Hi,

I am designing a small Windows Forms application, which will allow users to add/delete/view an item to/from Innovator database directly.

As we are not giving direct access to communicate with Innovator instance I am not using IOM.dll in my project. So, I am doing things through SQL queries. To add an item I did this,

To generate Ids:

   public static string GetUniqueID(int Size)
    {
        char[] validChars = new char[36];
        validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
        byte[] dataToAttr = new byte[1];
        using (RNGCryptoServiceProvider RNGCSP = new RNGCryptoServiceProvider())
        {
            RNGCSP.GetNonZeroBytes(dataToAttr);
            dataToAttr = new byte[Size];
            RNGCSP.GetNonZeroBytes(dataToAttr);
        }
        StringBuilder IDstring = new StringBuilder(Size);
        foreach (byte b in dataToAttr)
        {
            IDstring.Append(validChars[b % (validChars.Length)]);
        }
        return IDstring.ToString();
    }

This creates ids like : OB7NFUVH2SSGTANCCSY058EV8JOAU070, 2V35DB7328ULFYWMM43FMNCIQJZ5N9X0

To add an item:

string newID = GetUniqueID(32);

SqlCommand addItem = new SqlCommand("insert into [innovator].[NIS_ASSET](NAME, CONFIG_ID, ID, CREATED_BY_ID, CREATED_ON,PERMISSION_ID,KEYED_NAME,IS_CURRENT,GENERATION,MAJOR_REV,IS_RELEASED,NOT_LOCKABLE) values('" + NameTxt.Text + "','" + newID + "','" + newID + "','30B991F927274FA3829655F50C99472E', '" + dtNow + "', 0 , '9122CD065CF04141B8EFE263FC80BEA4','" + newID + "',1,1,'A',0,0)", connMIF);
            addItem.ExecuteNonQuery();

Here for PERMISSION_ID , I gave 'Default Access' item's id as value, for CREATED_BY_ID 'Innovator Admin' Item's id a s value and the same generated Id(newID) for KEYED_NAME.

Executes successfully. But when I try to open this in Innovator, recieving this "2V35DB7328ULFYWMM43FMNCIQJZ5N9X0 is not valid". After clicking OK form opens and displays data as well. But I am unable to edit and delete that item. Seeing the same error if I try to Lock/Delete the item.

Is this because of the ID that I am creating? or anything wrong with the query? Please give me some suggestions over this and help me.

 

Thank you,

Erg R


Viewing all articles
Browse latest Browse all 1103

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>