User 22c88daf92
		11-09-2013 06:48:16
	 
	
	
	Hello!
In the .net ,  I insert a structure to JchemBase table as follow code:
.............................................
            ConnectionHandler conh = GetConnectionHandler();
            UpdateHandler uh = new UpdateHandler(conh, UpdateHandler.INSERT, structureTableName, null); // "name, stock, comments");
            try
            {
                uh.setStructure(Encoding.Default.GetBytes("CCCCCC"));//hardcoded molecule CC
                uh.execute(); // How can I get the returned cd_id of this structure?
                MessageBox.Show("Done!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
...........................................................
How can I get the returned cd_id of this inserted structure? Is there any examples in c#?
thanks!
	
	 
 
	
		ChemAxon bd13b5bd77
		11-09-2013 07:46:05
	 
	
	
	 
Hi,
we have a good API description for that here: http://www.chemaxon.com/jchem/doc/dev/java/api/
Insert
You have two options to add/get id regarding the structure table:
- The id is autogenerated by our API (and  you do not want to generate a specific corporate id like this SEQUENCE_COMPANYNAME_DBID_PRODorTEST)
 
 UpdateHandler.INSERT is the proper parameter for the UpdateHandler class.
 int newID =  uh.execute(true);
 newID variable will contain the autgenerated id.
 
- The id you would like to generate e.g. bz callign a sequence and adding custom predefined codes.
 SEQUENCE_COMPANYNAME_DBID_PRODorTEST
 
 select SEQ_NO from dual;
 #ifdef DEBUG
 id = SEQ_NO + "_" + companyID + "_GLOBAL_" + TEST;
 #else
 id = SEQ_NO + "_" + companyID + "_GLOBAL_" + PROD;
 #endif
             in this situation please use:
          UpdateHandler.INSERT_WITH_ID is the proper parameter for the UpdateHandler class ==>
           var uh = new UpdateHandler(connectionHandler, UpdateHandler.INSERT_WITH_ID, ....
          updateHandler.setStructure(mrv);
          updateHandler.setID(id);
          updateHandler.execute(); 
Update
   In the case of update I think it is pretty obvious that you need to use UpdateHandler.UPDATE and
  updateHandler.setID(id);
  updateHandler.execute();