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. General Programming
  3. C#
  4. i need your help in ado.net

i need your help in ado.net

Scheduled Pinned Locked Moved C#
csharphelp
9 Posts 4 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.
  • M Offline
    M Offline
    mrx100
    wrote on last edited by
    #1

    i need your help ,i want to make selection of table to be dynamic corresponds to selected item from combobox more description //to be like that SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); //not SqlCommand cmd = new SqlCommand("select * from table1 ", con); and thanks

    Richard Andrew x64R 1 Reply Last reply
    0
    • M mrx100

      i need your help ,i want to make selection of table to be dynamic corresponds to selected item from combobox more description //to be like that SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); //not SqlCommand cmd = new SqlCommand("select * from table1 ", con); and thanks

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      And your problem is?

      The difficult we do right away... ...the impossible takes slightly longer.

      M 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        And your problem is?

        The difficult we do right away... ...the impossible takes slightly longer.

        M Offline
        M Offline
        mrx100
        wrote on last edited by
        #3

        i have more than one table and all of them have the same attributes i want to choose the table i want to get info from table i choose from combobox i want your help because this doesn't work SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); when i choose table from combobox like school this error showed : incorrect syntax near 'school'.

        Richard Andrew x64R 2 Replies Last reply
        0
        • M mrx100

          i have more than one table and all of them have the same attributes i want to choose the table i want to get info from table i choose from combobox i want your help because this doesn't work SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); when i choose table from combobox like school this error showed : incorrect syntax near 'school'.

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          But you have not made clear what your question is.

          The difficult we do right away... ...the impossible takes slightly longer.

          M 1 Reply Last reply
          0
          • M mrx100

            i have more than one table and all of them have the same attributes i want to choose the table i want to get info from table i choose from combobox i want your help because this doesn't work SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); when i choose table from combobox like school this error showed : incorrect syntax near 'school'.

            Richard Andrew x64R Offline
            Richard Andrew x64R Offline
            Richard Andrew x64
            wrote on last edited by
            #5

            Take out the single quotes from your query string. make it

            SqlCommand cmd = new SqlCommand("select * from " + comboBox1.SelectedItem.ToString(), con);

            The difficult we do right away... ...the impossible takes slightly longer.

            M P 2 Replies Last reply
            0
            • Richard Andrew x64R Richard Andrew x64

              But you have not made clear what your question is.

              The difficult we do right away... ...the impossible takes slightly longer.

              M Offline
              M Offline
              mrx100
              wrote on last edited by
              #6

              in my combobox i have places like: school hospital club each one is table in my database i want when i choose hospital it returns all hospitals i put in this table & its atributes and when i choose club it returns all clubs i put in this table & its atributes sorry for my bad english

              1 Reply Last reply
              0
              • Richard Andrew x64R Richard Andrew x64

                Take out the single quotes from your query string. make it

                SqlCommand cmd = new SqlCommand("select * from " + comboBox1.SelectedItem.ToString(), con);

                The difficult we do right away... ...the impossible takes slightly longer.

                M Offline
                M Offline
                mrx100
                wrote on last edited by
                #7

                thanks it works

                L 1 Reply Last reply
                0
                • Richard Andrew x64R Richard Andrew x64

                  Take out the single quotes from your query string. make it

                  SqlCommand cmd = new SqlCommand("select * from " + comboBox1.SelectedItem.ToString(), con);

                  The difficult we do right away... ...the impossible takes slightly longer.

                  P Offline
                  P Offline
                  ProEnggSoft
                  wrote on last edited by
                  #8

                  5!:thumbsup:

                  1 Reply Last reply
                  0
                  • M mrx100

                    thanks it works

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    IMO if you had written the failing SQL statement to the console (or to a log file) you would easily have seen where it went wrong yourself. :) PS: if your combobox allows editing, your SQL statement is open for injection attacks, and people could easily delete your tables...

                    Luc Pattyn [My Articles] Nil Volentibus Arduum

                    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