Save Entity without PK

Posts   
 
    
lgege
User
Posts: 27
Joined: 01-Sep-2005
# Posted on: 10-Nov-2005 15:36:34   

Hi,

I have a table without PK or Unique Constaints. If I save a new entity, it works without any problems. But when I try to modify an existing one, it always gives me the error below.

The code for saving is "adapter.SaveEntity(wot, False, Nothing, True)". I load the entity first and make the changes. So I am pretty sure the entity is not Nothing. Is it possible that this is because the table doesn't have any PK or Unique Contraints?

Thanks

Object reference not set to an instance of an object.

Server stack trace: at Sears.UltraCare.BL.RM.PriceManager.SaveWebOfferTemplate(ScucwebOfferTemplate wot) in C:#local files\clients\sears\UltraCare2\Sears.UltraCare.BL.RM\PriceManager.vb:line 541 at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Sears.UltraCare.BL.RM.Interfaces.IPriceManager.SaveWebOfferTemplate(ScucwebOfferTemplate wot) at Sears.UltraCare.PL.UltraCareWeb.EditWebOfferTemplate.btnSave_Click(Object sender, EventArgs e) in C:#local files\clients\sears\phase1\Construction\Code\UltraCareWeb\WebModules\Admin\EditWebOfferTemplate.aspx.vb:line 144

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 10-Nov-2005 17:08:05   

correct. It can't save it, because it can't produce the where filter as there's no PK. Add a PK in the designer or in the DB

Frans Bouma | Lead developer LLBLGen Pro
lgege
User
Posts: 27
Joined: 01-Sep-2005
# Posted on: 10-Nov-2005 17:18:54   

Does adding a Unique Constraint help?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 10-Nov-2005 18:02:26   

lgege wrote:

Does adding a Unique Constraint help?

No simple_smile .

Though you can simply select a field in the entity editor in llblgen pro and make it the PK, save the project, re-generate the code and you're set.

Frans Bouma | Lead developer LLBLGen Pro