Help needed urgent
-
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? :)
-
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? :)
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/
-
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? :)
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
-
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