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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Invalid column

Invalid column

Scheduled Pinned Locked Moved ASP.NET
helpquestion
5 Posts 5 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.
  • P Offline
    P Offline
    Paresh1462
    wrote on last edited by
    #1

    i got error : Invalid column name 'A1009'.

            chk1 = "select Sno from Student where SID = "+ @smemno.Text.ToString();
            
            SqlCommand ck1 = new SqlCommand(chk1, cn);
            
            v11 = (string)ck1.ExecuteScalar();
    

    what should i do?

    N G P W 4 Replies Last reply
    0
    • P Paresh1462

      i got error : Invalid column name 'A1009'.

              chk1 = "select Sno from Student where SID = "+ @smemno.Text.ToString();
              
              SqlCommand ck1 = new SqlCommand(chk1, cn);
              
              v11 = (string)ck1.ExecuteScalar();
      

      what should i do?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Paresh1462 wrote:

      what should i do?

      Realize that we are not looking over your shoulder. Give an accurate description of the conditions, your problem, expected outcome and what you have tried. Without knowing your database structure or what it is populated with how can we tell what column A1009 means?


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • P Paresh1462

        i got error : Invalid column name 'A1009'.

                chk1 = "select Sno from Student where SID = "+ @smemno.Text.ToString();
                
                SqlCommand ck1 = new SqlCommand(chk1, cn);
                
                v11 = (string)ck1.ExecuteScalar();
        

        what should i do?

        G Offline
        G Offline
        GenJerDan
        wrote on last edited by
        #3

        chk1 = "select Sno from Student where SID = '"+ @smemno.Text.ToString()+"'";

        will probably fix it, but as Mark said, more details would help tremendously.

        There is water at the bottom of the ocean. My Mu[sic] My Films My Windows Programs, etc.

        1 Reply Last reply
        0
        • P Paresh1462

          i got error : Invalid column name 'A1009'.

                  chk1 = "select Sno from Student where SID = "+ @smemno.Text.ToString();
                  
                  SqlCommand ck1 = new SqlCommand(chk1, cn);
                  
                  v11 = (string)ck1.ExecuteScalar();
          

          what should i do?

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          For a start, I would look to change your code to mitigate the chance that you will be left wide open to a Sql Injection attack[^]. Secondly, I would look to Dispose of my SqlCommand object. Wrapping it in a nice using statement will do the trick.

          I'm not a stalker, I just know things. Oh by the way, you're out of milk.

          Forgive your enemies - it messes with their heads

          My blog | My articles | MoXAML PowerToys | Onyx

          1 Reply Last reply
          0
          • P Paresh1462

            i got error : Invalid column name 'A1009'.

                    chk1 = "select Sno from Student where SID = "+ @smemno.Text.ToString();
                    
                    SqlCommand ck1 = new SqlCommand(chk1, cn);
                    
                    v11 = (string)ck1.ExecuteScalar();
            

            what should i do?

            W Offline
            W Offline
            Wendelius
            wrote on last edited by
            #5

            As already pointed out, use parameters: SqlParameter[^]. But if you still for some reason want to use literals in SQL statements, add apostrophes when you're adding texts to the statement:

            chk1 = "select Sno from Student where SID = '"+ @smemno.Text.ToString() + "'";

            The need to optimize rises from a bad design.My articles[^]

            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