Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. ExecutiveNonQuery() returns 0

ExecutiveNonQuery() returns 0

Scheduled Pinned Locked Moved Database
helpcsharpdatabasequestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hkl
    wrote on last edited by
    #1

    I have a question about using ExecutiveNonQuery() in C# (using Access). The following code would return 0, when I specify "@myMax".Value = 1 (see below). However, if I changed @myMax to a constant (ie. not using a variable), everything worked fine and it returned 1 as the result. The problem is that since it doesn't throw an exception, and only returns 0, I have no idea what's wrong with the "Update" SQL statement. Thank you and appreciate any feedbacks!! // Updates the MAX, and NOTE field of a particular record OleDbCommand myUpdate = new OleDbCommand("UPDATE Product SET **Prod_max = @myMax**, Prod_desc = @myNote WHERE Prod_id = @myID", oleDbConnection1); myUpdate.Parameters.Add("@myNotes", OleDbType.LongVarWChar); myUpdate.Parameters.Add("@myID", OleDbType.VarChar); myUpdate.Parameters.Add("@myMax", OleDbType.SmallInt); myUpdate.Parameters["@myNotes"].Value = Notestxtbox.Text.ToString(); myUpdate.Parameters["@myID"].Value = ProdIDtxtbox.Text.ToString(); **myUpdate.Parameters["@myMax"].Value = 1;** try { textBox1.Text = myUpdate.ExecuteNonQuery().ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK,MessageBoxIcon.Exclamation); }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups