Click here to Skip to main content
15,875,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wanted to set subject=null in a row but i am getting this wrong answer

my code :

C#
using (
      SqlConnection con =
          new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString))
           {
               con.Open();
               using (SqlCommand cmd = new System.Data.SqlClient.SqlCommand("UPDATE RESULT_TABLE  SET  SUBJECT = NULLL where ROLL  = @ROLL", con))
               {
                   cmd.Parameters.AddWithValue("@ROLL", roll.Text);



                   //cmd.Parameters.AddWithValue("@ROLL", roll2.Text);
                   cmd.ExecuteNonQuery();
               }




i am getting "invalid coloumn name NULL" this wrong answer.
if i use string =NULL instead using direct NULL how can i do that.
Posted
Comments
Afzaal Ahmad Zeeshan 20-Jan-16 4:18am    
In your code, you not using NULL, instead it is NULLL.

Also, the error message is for the column name, which means that you are somewhere trying to reference a column using NULL, and NULL cannot be a column name.

1 solution

Take out one of the "L"s:
C#
using (SqlCommand cmd = new System.Data.SqlClient.SqlCommand("UPDATE RESULT_TABLE  SET  SUBJECT = NULLL where ROLL  = @ROLL", con))

Becomes:
C#
using (SqlCommand cmd = new System.Data.SqlClient.SqlCommand("UPDATE RESULT_TABLE  SET  SUBJECT = NULL where ROLL  = @ROLL", con))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900