Getting back into LLBLGen Pro

Posts   
 
    
Rainbow
User
Posts: 29
Joined: 23-Feb-2004
# Posted on: 29-Nov-2004 23:18:04   

Hi,

I've been away for about 5 months and have gotten rusty again confused

I generated code, looked at the help (Will there be additional tutorials, examples in the future?) but get this error and dont know why:

The entity is out of sync with its data in the database. Refetch this entity before using this in-memory instance

public static void BindUserInformation(System.Guid userID, ref string userName, ref string lastSent, ref string userDescription,ref string userEmail)
        {
            DataAccessAdapter adapter = new DataAccessAdapter();
            UserEntity user = new UserEntity(userID);
            adapter.FetchEntity(user);

            userName = user.Name;
            lastSent = user.LastSent.ToShortDateString();
            userDescription = user.Description;
            userEmail = user.Email;
        }

I'm trying to avoid using the llblgen code directly in my codebehind file so I am populating the required string values for the ascx page.

Can anyone see what is wrong with this code?

Thanks,

John

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 30-Nov-2004 01:25:17   

I think if the value of user.IsNew = true after the adapter.FetchEntity(user); then that would cause the exception.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 30-Nov-2004 10:23:44   

Rainbow wrote:

Hi,

I've been away for about 5 months and have gotten rusty again confused

I generated code, looked at the help (Will there be additional tutorials, examples in the future?) but get this error and dont know why:

there will be more examples in the (near) future, and more How do I? questions in the documentation. The latest docs are already a huge step forward compared to the docs of a few months ago. simple_smile

The entity is out of sync with its data in the database. Refetch this entity before using this in-memory instance

public static void BindUserInformation(System.Guid userID, ref string userName, ref string lastSent, ref string userDescription,ref string userEmail)
        {
            DataAccessAdapter adapter = new DataAccessAdapter();
            UserEntity user = new UserEntity(userID);
            adapter.FetchEntity(user);

            userName = user.Name;
            lastSent = user.LastSent.ToShortDateString();
            userDescription = user.Description;
            userEmail = user.Email;
        }

I'm trying to avoid using the llblgen code directly in my codebehind file so I am populating the required string values for the ascx page.

FetchEntity() returns false I think, i.e.: userID contains a PK value that's not found in the DB.

Frans Bouma | Lead developer LLBLGen Pro
Rainbow
User
Posts: 29
Joined: 23-Feb-2004
# Posted on: 30-Nov-2004 23:52:47   

Hi Guys, yep was passing in the wrong userID flushed

Thanks for answering.

So if(user.IsNew)

it means nothing was returned? Or would I check for if(user == null).

Thanks guys,

John

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 01-Dec-2004 09:38:54   

Check the return value of FetchEntity simple_smile If it's false, nothing is fetched, if it's true, fetch succeeded simple_smile

Frans Bouma | Lead developer LLBLGen Pro