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. What is wrong ?

What is wrong ?

Scheduled Pinned Locked Moved ASP.NET
questionwpfwcfhelp
3 Posts 2 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
    A kamath
    wrote on last edited by
    #1

    I am trying to do a search. When I type a character inside the textbox it should take all the feild value which starts with that character. Below code it is not showing any error, but not binding to the datagrid. string s = "%S" + TextBox5.Text + "%"; string d = "SELECT field1, field2,... FROM OUTSTANDING WHERE field1 LIKE '"+ s +"'"; try{ OdbcCommand CMD = new OdbcCommand(d, c); DataSet DT = new DataSet(); c.Open(); OdbcDataAdapter a = new OdbcDataAdapter(CMD); CMD.ExecuteNonQuery(); a.Fill(DT, Tablename); GridView1.DataSource = DT; GridView1.DataBind(); }

    C 1 Reply Last reply
    0
    • A A kamath

      I am trying to do a search. When I type a character inside the textbox it should take all the feild value which starts with that character. Below code it is not showing any error, but not binding to the datagrid. string s = "%S" + TextBox5.Text + "%"; string d = "SELECT field1, field2,... FROM OUTSTANDING WHERE field1 LIKE '"+ s +"'"; try{ OdbcCommand CMD = new OdbcCommand(d, c); DataSet DT = new DataSet(); c.Open(); OdbcDataAdapter a = new OdbcDataAdapter(CMD); CMD.ExecuteNonQuery(); a.Fill(DT, Tablename); GridView1.DataSource = DT; GridView1.DataBind(); }

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Your code is not secure, but I assume from the variable names that this isn't code that will be used in the real world anyhow ?

      A kamath wrote:

      string s = "%S" + TextBox5.Text + "%";

      If you type in e, you will search for anything that starts with Se. Turn %S into % and it will work the way you described it.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      A 1 Reply Last reply
      0
      • C Christian Graus

        Your code is not secure, but I assume from the variable names that this isn't code that will be used in the real world anyhow ?

        A kamath wrote:

        string s = "%S" + TextBox5.Text + "%";

        If you type in e, you will search for anything that starts with Se. Turn %S into % and it will work the way you described it.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        A Offline
        A Offline
        A kamath
        wrote on last edited by
        #3

        Thanks a million. It is working hurray

        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