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. General Programming
  3. C#
  4. Error: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.

Error: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.

Scheduled Pinned Locked Moved C#
databasehelpsysadminannouncement
2 Posts 2 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.
  • O Offline
    O Offline
    Omar Akhtar Sheikh
    wrote on last edited by
    #1

    I am using a datagridview with an INSERT, DELETE and an UPDATE button. But whenever I run my form the error that I have stated above rises. Kindly help me to solve this problem. <code>             string constr = "Server=PACE-BB95D506B2; Database=Dotnet67;                                                                                                                  uid=sa; pwd=123";                                     private void button1_Click(object sender, EventArgs e)             {                   this.Close();             }                                     DataTable table = null;             SqlDataAdapter da = null;             private void LoadCashiers()             {                   string query = "SELECT * FROM Cashier_2";                   da = new SqlDataAdapter(query, constr);                   table = new DataTable();                   da.Fill(table);                   dataGridView1.DataSource = table;                   dataGridView1.Refresh();                   SqlCommandBuilder b = new SqlCommandBuilder(da);

    M 1 Reply Last reply
    0
    • O Omar Akhtar Sheikh

      I am using a datagridview with an INSERT, DELETE and an UPDATE button. But whenever I run my form the error that I have stated above rises. Kindly help me to solve this problem. <code>             string constr = "Server=PACE-BB95D506B2; Database=Dotnet67;                                                                                                                  uid=sa; pwd=123";                                     private void button1_Click(object sender, EventArgs e)             {                   this.Close();             }                                     DataTable table = null;             SqlDataAdapter da = null;             private void LoadCashiers()             {                   string query = "SELECT * FROM Cashier_2";                   da = new SqlDataAdapter(query, constr);                   table = new DataTable();                   da.Fill(table);                   dataGridView1.DataSource = table;                   dataGridView1.Refresh();                   SqlCommandBuilder b = new SqlCommandBuilder(da);

      M Offline
      M Offline
      Moreno Airoldi
      wrote on last edited by
      #2

      The error means you don't have a primary key defined in your database table. A primary key is mandatory if you want to use SqlCommandBuilder. You must either define a primary key in the database table or write the code to build the insert, delete and update SQL commands by hand.

      2+2=5 for very large amounts of 2 (always loved that one hehe!)

      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