| 
                   
                			                                                     		            
                
                    
                             
                    
                
                Michael Reese
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Users 	        
    Posts: 235, 
    Visits: 1.6K 
    
 
          
		     | 
				                       
                 
                
                    
			            I am getting an error adding a record to a table that does not have a primary key. The message states that I cannot insert a command because PrimaryKeyisAutoincremented = true and the PrimaryKeyField is not a valid auro-increment data type. 
  The table does not have a Primary Key or autoincrementing primary key set to Auto increment. 
  Any Ideas? 
  Sample code below.
                                  '-- Create a new record                                 .NewRow()                                 'Save Log Record                                 LocHL7Data.MessageID = System.Guid.NewGuid.ToString() 'Loc_PID_SEG_BO.MessageID                                 'LocHL7Data.MessageSize = oMsg.                                 LocHL7Data.VendorVersion = oMsg.VendorVersion                                 LocHL7Data.VendorName = oMsg.VendorName                                 LocHL7Data.MsgControl = sCrlID                                 LocHL7Data.PartnerAPP = ""                                 LocHL7Data.DateLoaded = System.DateTime.Now.ToString                                 LocHL7Data.HL7Message = oMsg.HL7                                 LocHL7Data.SegmentCount = oMsg.SegmentCount                                 LocHL7Data.MsgType = sMsgType1
                                  '-- Save the record                                 If .Save() <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then                                     MsgBox("Save Failed...")                                 End If                             End With                
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                StrataFrame Team
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Developers 	        
    Posts: 3K, 
    Visits: 2.5K 
    
 
          
		     | 
				                       
                 
                
                    
			            On the business object itself, is the PrimaryKeyIsAutoIncremented property set to True?  It should be in the CRUD category in the designer. It doesn't matter how the data source's table is actually configured.  If that property on the business object it True, it's going to cause that error.                
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                Michael Reese
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Users 	        
    Posts: 235, 
    Visits: 1.6K 
    
 
          
		     | 
				                       
                 
                
                    
			            Thanks Ben, 
  That did it. 
  So, now I have another problem. The business object throws an error when I save to another table that does not have a primary key when I attempt to create a record.
  Thanks
  Michael                 
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                StrataFrame Team
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Developers 	        
    Posts: 3K, 
    Visits: 2.5K 
    
 
          
		     | 
				                       
                 
                
                    
			            Hrm.  What is the exception that it throws?                
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                Edhy Rijo
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Users 	        
    Posts: 2.4K, 
    Visits: 23K 
    
 
          
		     | 
				                       
                 
                
                    
			            Hi Michael, You manage these properties on a per BO basis so you have to make sure you configure each BO as its table requires.  Look at those properties descriptions and you should be able to set them properly as needed.                
			            				
			             Edhy Rijo                     
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                Michael Reese
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Users 	        
    Posts: 235, 
    Visits: 1.6K 
    
 
          
		     | 
				                       
                 
                
                    
			            Thanks, I was looking for that in the BO properties but could not find it. 
  This is the exception thrown
  Is says that DataLayer Exception "Cannot Create Insert command because the BO does not contain any primaryKeyFields.                
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                StrataFrame Team
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Developers 	        
    Posts: 3K, 
    Visits: 2.5K 
    
 
          
		     | 
				                       
                 
                
                    
			            That's correct.  StrataFrame requires that each table have a PrimaryKey.  It needs this so that it knows how to save an individual row.  Without a PK, StrataFrame would be able to insert rows, but it would not be able to update or delete those rows.  It does not have the functionality to do an update or a delete with a complex where clause; the only where clause it can generate for an update or delete is the matching of the PK value. In fact, this is something we debated for SFv2... do we allow entities to map to tables that do not have a primary key.  We ended up on the same side of the fence as SFv1, which is that each table requires a PK.  Pre-beta, it's certainly not set in stone, so I could be convinced otherwise. Would it break your database logic to add a PK to the table?  Do you ever need to be able to update/delete rows in this table, or only insert them?  Without a PK, you would have to manually specify the where conditions during an update or delete.  Let me know.                
			            				
			                                 
                     
                                            
                         
                    
                  
              | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                Michael Reese
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Users 	        
    Posts: 235, 
    Visits: 1.6K 
    
 
          
		     | 
				                       
                 
                
                    
			            Thanks Ben, 
  I guess I could but it will take a lot of work. 
  I have created and HL7 data warehouse that reads HL7 messages and parse the data into segment tables. This is why
  MSH MessageID = Generated
  PID MessageID = MSH MessageID
  OBX MessageID = MSH MessageID
  NTE MessageID = MSH MessageID
  Im dealing in millions.                
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                StrataFrame Team
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Developers 	        
    Posts: 3K, 
    Visits: 2.5K 
    
 
          
		     | 
				                       
                 
                
                    
			            HL7 you probably never update the records.  If you delete an entire message, then you also delete all of the children with the same MessageID, yes? So, the children all have a foreign key to the MessageID of the MSH... it would make sense for that to be the clustered index of the table. I think the best way of doing this would be to leave the PrimaryKeyIsAutoIncremented set to false, that lets you assign the primary key and tells SF not to negative increment the column.  Then, move the Public Overrides ReadOnly Property PrimaryKeyFields As String() from the designer file to your main file and return "MessageID" or whatever field name you need in the string array rather than an empty string array.  Moving this to the main code file will keep it from being overriden when you re-map your business objects.  Instead, when you rebuild the partial classes, it will regenerate the PrimaryKeyFields property and you will need to go delete it from the designer file before you can build (better than figuring out at runtime that it's wrong).   This will trick SF into thinking that MessageID is the PK for each of the BOs, but will still let you insert the value rather than expecting it from the database. Give that a try and let me know.  I'll make sure we have a graceful way to handle it for SFv2                   
			            				
			                                
                     
                                            
                         
                    
                  
              | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     | 
			
						
	           
    		
	    
				| 
                   
                			                                                     		            
                
                    
                             
                    
                
                Michael Reese
                
             | 
				
                
                
                                
               
                	
             | 
			
			
		
				| 
		        
                
 
 
	Group: StrataFrame Users 	        
    Posts: 235, 
    Visits: 1.6K 
    
 
          
		     | 
				                       
                 
                
                    
			            Thanks , I'll give is a shot. I want to do as much as I can through the SF BOs. 
  I'm rewriting (2 years old application) a solution and was wondering how I successfully pulled it off before and then checked my my code and realized that I used a ADOSqlServer connection on these tables. 
  Michael                
			            				
			                                 
                     
                                            
                         
                    
                  
             | 
			
			
        
				|            
                            
		     | 
						
			
			            
           
			    			
                 
                    
                 
		     |