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. Web Development
  3. ASP.NET
  4. inserting listbox item into databse

inserting listbox item into databse

Scheduled Pinned Locked Moved ASP.NET
help
5 Posts 2 Posters 1 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.
  • K Offline
    K Offline
    Kunal P
    wrote on last edited by
    #1

    hi i just wanted help to insert a single listbox item into the databse. lb.Text = ListBox1.SelectedValue.ToString(); cmd2.CommandText = "Insert into Bill(BillNo,PatID,Test) Values('" + maxlbl.Text + "','" + patid.Text + "','" +lb.Text+ "' "; now, wat should be correct statement to set the label text of the listitem that is currently selected.

    Kunal

    N 1 Reply Last reply
    0
    • K Kunal P

      hi i just wanted help to insert a single listbox item into the databse. lb.Text = ListBox1.SelectedValue.ToString(); cmd2.CommandText = "Insert into Bill(BillNo,PatID,Test) Values('" + maxlbl.Text + "','" + patid.Text + "','" +lb.Text+ "' "; now, wat should be correct statement to set the label text of the listitem that is currently selected.

      Kunal

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

      First, you should be using stored procedures. If you can't then at least use a SqlCommand and SqlParameters. Second, never allow unvalidated text to be inserted into your command or database.


      only two letters away from being an asset

      K 1 Reply Last reply
      0
      • N Not Active

        First, you should be using stored procedures. If you can't then at least use a SqlCommand and SqlParameters. Second, never allow unvalidated text to be inserted into your command or database.


        only two letters away from being an asset

        K Offline
        K Offline
        Kunal P
        wrote on last edited by
        #3

        i know its bad programming practice, and very much prone to sql injection... but just a mini project thing.. for some hit and trial..

        Kunal

        N 1 Reply Last reply
        0
        • K Kunal P

          i know its bad programming practice, and very much prone to sql injection... but just a mini project thing.. for some hit and trial..

          Kunal

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

          All the more reason to practice more correct techniques. When the deadline is near you will code what is quick and spend hours debugging and fixing afterward.


          only two letters away from being an asset

          K 1 Reply Last reply
          0
          • N Not Active

            All the more reason to practice more correct techniques. When the deadline is near you will code what is quick and spend hours debugging and fixing afterward.


            only two letters away from being an asset

            K Offline
            K Offline
            Kunal P
            wrote on last edited by
            #5

            hmm.. thats a point.. should go for the best possible practices.. cmd.Parameters.Add(); @list now how do i pass the listbox item value into this..

            Kunal

            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