Insert problems

Posts   
 
    
Posts: 13
Joined: 04-Mar-2005
# Posted on: 15-Apr-2005 16:48:28   

Hi

I have been having a hell of a time trying to get some LLBLGen code working. Firstly I had a problem where it was generating duplicate functions (with identical signatures) in the same classes, but I fixed this by rebuilding the database from scratch and it worked - strange?

Now I am unable to save a new entity to an empty table. I am using Microsoft Access and the table (called tblMessage) I am INSERTING into is:

MsgID, AutoNumber (Long Integer), Primary Key MsgDateTime, Date/Time, Reqd MsgTo, Text MsgFrom, Text MsgSubject, Text MsgText, Memo

This is the function I have for saving the data to the DL:

Dim message As MessageEntity = New MessageEntity

message.MsgTo = "All"
message.MsgDateTime = DateTime.Now
message.MsgText = "Some message"

Return message.Save()

When I set a breakpoint in the AddMessage function of the MessageDAO class an exception is thrown when the Base.ExecuteActionQuery is reached. I have checked the query being executed and this is also below.

Public Function AddMessage(fields As IEntityFields, containingTransaction As ITransaction) As Boolean
    If fields Is Nothing Then
        Throw New ArgumentNullException("fields", "fields can't be null")
    End If

    Dim insertQuery As IActionQuery = DynamicQueryEngine.CreateInsertDQ(fields, DbUtils.DetermineConnectionToUse(containingTransaction))
    Dim wasSuccesful As Boolean = (MyBase.ExecuteActionQuery(insertQuery, containingTransaction) > 0)
    If wasSuccesful Then
        insertQuery.ReflectOutputValuesInRelatedFields()
    End If
    Return wasSuccesful
End Function

"INSERT INTO [tblMessage] ([MsgDateTime],[MsgTo],[MsgText]) VALUES (@MsgDateTime,@MsgTo,@MsgText)"

The error message displayed back to the browser window is:

An exception was caught during the execution of an action query: Operation must use an updateable query.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

PLEASE HELP!!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Apr-2005 17:35:25   

This is a JET error, as I find a lot of replies when I search for "Operation must use an updateable query" INSERT on google groups.

Please check if the .mdb file is WRITABLE for the user which runs the website (Typically that's the ASPNET user). Also, be sure that that user is able to CREATE files in the folder in which the .mdb file is located, as it has to create a lock file.

edit: also check: http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14520

(yes, that's macromedia wink )

Frans Bouma | Lead developer LLBLGen Pro
Posts: 13
Joined: 04-Mar-2005
# Posted on: 18-Apr-2005 02:14:51   

Frans,

You're an absolute champion. In my frustration I didn't even bother to check Google. Apologies, it certainly wasn't LLBLGen giving me grief. Thanks for your help again!!

Cheers mate

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 18-Apr-2005 09:13:55   

smile Glad it's solved simple_smile

Frans Bouma | Lead developer LLBLGen Pro