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. Help needed urgent

Help needed urgent

Scheduled Pinned Locked Moved C#
databasehelpcsharpasp-netsql-server
4 Posts 3 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
    ashkitt
    wrote on last edited by
    #1

    Hi im making a simple ASP.NET Web Application.with SQL Server 2000 to delete a record from the database, i use the following query "delete from Temp1 where FirstName = '"+ TextBox1.Text + "';"; i get the following server error: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. what shud i do? :)

    V R 2 Replies Last reply
    0
    • A ashkitt

      Hi im making a simple ASP.NET Web Application.with SQL Server 2000 to delete a record from the database, i use the following query "delete from Temp1 where FirstName = '"+ TextBox1.Text + "';"; i get the following server error: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. what shud i do? :)

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      ashkitt, You can use the ID (userId) or the related column right. Text comparisons are slower. Also, one suggestion. Comparing against TextBox1.Text directly in a query is a potentially dangerous thing and that too in a Web Application, which I think would open doors for SQL Injection attacks. You may like to move this into a Stored Procedure rather. Vasudevan Deepak Kumar Personal Web: http://www.lavanyadeepak.tk/ I Blog At: http://deepak.blogdrive.com/

      1 Reply Last reply
      0
      • A ashkitt

        Hi im making a simple ASP.NET Web Application.with SQL Server 2000 to delete a record from the database, i use the following query "delete from Temp1 where FirstName = '"+ TextBox1.Text + "';"; i get the following server error: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. what shud i do? :)

        R Offline
        R Offline
        Rob Graham
        wrote on last edited by
        #3

        Change the data type of the FirstName field to VarChar or NVarchar. You don't need a text or ntext field for this, FirstName should not exceed 4000 characters...(limit for the size of an nvarchar is 4000 unicode characters) Don't arbitrarily make fields text,ntext or image type, since, as you have seen, they can't be compared... They are also substantially slower to retrieve as the always involve an extra level of indirection in the database. Absolute faith corrupts as absolutely as absolute power Eric Hoffer All that is necessary for the triumph of evil is that good men do nothing. Edmund Burke

        A 1 Reply Last reply
        0
        • R Rob Graham

          Change the data type of the FirstName field to VarChar or NVarchar. You don't need a text or ntext field for this, FirstName should not exceed 4000 characters...(limit for the size of an nvarchar is 4000 unicode characters) Don't arbitrarily make fields text,ntext or image type, since, as you have seen, they can't be compared... They are also substantially slower to retrieve as the always involve an extra level of indirection in the database. Absolute faith corrupts as absolutely as absolute power Eric Hoffer All that is necessary for the triumph of evil is that good men do nothing. Edmund Burke

          A Offline
          A Offline
          ashkitt
          wrote on last edited by
          #4

          Thanx Rob, Problem solved:o) :)

          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