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. delete error from database

delete error from database

Scheduled Pinned Locked Moved C#
databasecomhelp
4 Posts 4 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.
  • A Offline
    A Offline
    Ashraf zia
    wrote on last edited by
    #1

    i am deleting a record from the database and i get an exception message : datatype mismatch, i have the following query for deleting a reocrd from the database: string query = "delete from registration where id = '"+ Convert.ToInt16(this.id.Text)+"'"; its point to the line 568 which contains: com.ExcecuteNonQuery();

    E R E 3 Replies Last reply
    0
    • A Ashraf zia

      i am deleting a record from the database and i get an exception message : datatype mismatch, i have the following query for deleting a reocrd from the database: string query = "delete from registration where id = '"+ Convert.ToInt16(this.id.Text)+"'"; its point to the line 568 which contains: com.ExcecuteNonQuery();

      E Offline
      E Offline
      Elina Blank
      wrote on last edited by
      #2

      What is the type of your id column. According to your query it must be tinyint. do Convert.ToInt32, if it is of type int

      Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O

      1 Reply Last reply
      0
      • A Ashraf zia

        i am deleting a record from the database and i get an exception message : datatype mismatch, i have the following query for deleting a reocrd from the database: string query = "delete from registration where id = '"+ Convert.ToInt16(this.id.Text)+"'"; its point to the line 568 which contains: com.ExcecuteNonQuery();

        R Offline
        R Offline
        Russell Jones
        wrote on last edited by
        #3

        if it's an int type you shouldn't use the single quote characters what db are you using sql server normally likes delete where id = 7 access tends to like Delete * from where id = 7 i would guess it's a type conversion thing though, by putting the ' char in you make the data provider pass it as a string type HTH Russ

        1 Reply Last reply
        0
        • A Ashraf zia

          i am deleting a record from the database and i get an exception message : datatype mismatch, i have the following query for deleting a reocrd from the database: string query = "delete from registration where id = '"+ Convert.ToInt16(this.id.Text)+"'"; its point to the line 568 which contains: com.ExcecuteNonQuery();

          E Offline
          E Offline
          ednrgc
          wrote on last edited by
          #4

          remove the single quotes and it will work.

          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