CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2001
    Location
    Israel
    Posts
    116

    INSERT INTO Query

    Hi

    I am using the query:

    INSERT INTO Brands ([BName],[BDescription],[PicturePath]) VALUES ('mm','mm','mm')

    by using the "ExecuteNonQuery" of "OleDbCommand".

    and i am getting the error:
    "Operation must use an updateable query. "

    I tried to execute the same query directly from the
    mdb file and it's working.

    any ideas?

    Thanks
    Limor

  2. #2
    Join Date
    Mar 2003
    Posts
    4
    Hi
    Please check the constraints once again and check the autonumber column(Primary Key) working properly!!

    thanks
    Murali

  3. #3
    Join Date
    Dec 2002
    Location
    Sioux Falls, SD, USA
    Posts
    40
    I don't think you can use ExecuteNonQuery when executing queries like that (hence the name ExecuteNONQuery). I think it's for executing stored procedures. Use ExecuteScalar instead.

    Hope this helps.
    Do what thou wilt, shall be the whole of the law.

  4. #4
    Join Date
    Mar 2003
    Posts
    4
    ExecuteScalar will return only firstcolumn of the firstrow in the resultset. ExecuteNonQuery returns the count of records affected.

    ExecuteNonQuery is the correct one in this case but I think there is something wrong in the database side or at the code part. Paste the Insert code part over here.

  5. #5
    Join Date
    Mar 2001
    Location
    Israel
    Posts
    116
    INSERT INTO Brands ([BName],[BDescription],[PicturePath]) " & _
    "VALUES ('nameStr','decStr','pathStr')
    i took this query and run it from the access file and it's working.

    it gives me the same error when i use the UPDATE query
    i am using this syntax all the time.
    this is the first time i get this error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured