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 help

i need help

Scheduled Pinned Locked Moved C#
databasehelpquestion
11 Posts 6 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 Mohamed El Wehishy

    hi guys i have table in sqlserver database named tels has columns tels_no , tels_name , tels_cost ok i want to enter a no in a textbox in the application then auto it get data of this no and set this in two different textboxes one for tels_name and other for tels_cost how?????????? i do not know thanks, Mohamed El-Wehishy

    B Offline
    B Offline
    Blikkies
    wrote on last edited by
    #2

    You can use ADO.net or data set to get you data from DB.

    G 1 Reply Last reply
    0
    • B Blikkies

      You can use ADO.net or data set to get you data from DB.

      G Offline
      G Offline
      Greg Chelstowski
      wrote on last edited by
      #3

      Yeah, great answer. I'd mark it as "bestest ever" but the developers of this site probably never knew you'd come along...

      Blikkies wrote:

      You can use ADO.net or data set to get you data from DB.

      What the hell does that bring to anything? It's like somebody asked: "I'm having trouble fitting windows in my house, I know where I want them and I have a fitting kit for them" and you answered "You can use a hammer or its handle to bang nails into a wall." As for the author of the question, you'd be better off reading a book on C# and/or a tutorial online. Rome was not built in a day.

      var question = (_2b || !(_2b));

      B M 2 Replies Last reply
      0
      • G Greg Chelstowski

        Yeah, great answer. I'd mark it as "bestest ever" but the developers of this site probably never knew you'd come along...

        Blikkies wrote:

        You can use ADO.net or data set to get you data from DB.

        What the hell does that bring to anything? It's like somebody asked: "I'm having trouble fitting windows in my house, I know where I want them and I have a fitting kit for them" and you answered "You can use a hammer or its handle to bang nails into a wall." As for the author of the question, you'd be better off reading a book on C# and/or a tutorial online. Rome was not built in a day.

        var question = (_2b || !(_2b));

        B Offline
        B Offline
        Blikkies
        wrote on last edited by
        #4

        Greg Chelstowski wrote:

        What the hell does that bring to anything?

        at least i gave him something to google.

        1 Reply Last reply
        0
        • M Mohamed El Wehishy

          hi guys i have table in sqlserver database named tels has columns tels_no , tels_name , tels_cost ok i want to enter a no in a textbox in the application then auto it get data of this no and set this in two different textboxes one for tels_name and other for tels_cost how?????????? i do not know thanks, Mohamed El-Wehishy

          B Offline
          B Offline
          Blikkies
          wrote on last edited by
          #5

          SqlConnection conn = new SqlConnection(@"user id=sa; Password=pass; initial catalog=databaseName; Data source=localhost");
          conn.Open();
          SqlCommand cmd = conn.CreateCommand();
          cmd.CommandText = "SELECT * FROM Tabel WHERE tels_no = '"+textbox1.Text.Replace("'","")+"'";
          SqlDataReader reader = cmd.ExecuteReader();
          while(reader.Read())
          {
          TextBox2.Text = reader["tels_name"].ToString();
          }

          Use following namespaces: using System.Data; using System.Data.SqlClient;

          M 1 Reply Last reply
          0
          • G Greg Chelstowski

            Yeah, great answer. I'd mark it as "bestest ever" but the developers of this site probably never knew you'd come along...

            Blikkies wrote:

            You can use ADO.net or data set to get you data from DB.

            What the hell does that bring to anything? It's like somebody asked: "I'm having trouble fitting windows in my house, I know where I want them and I have a fitting kit for them" and you answered "You can use a hammer or its handle to bang nails into a wall." As for the author of the question, you'd be better off reading a book on C# and/or a tutorial online. Rome was not built in a day.

            var question = (_2b || !(_2b));

            M Offline
            M Offline
            Mohamed El Wehishy
            wrote on last edited by
            #6

            :laugh: yesssssss man you are right sorry for this silly question Mohamed El-Wehishy

            1 Reply Last reply
            0
            • B Blikkies

              SqlConnection conn = new SqlConnection(@"user id=sa; Password=pass; initial catalog=databaseName; Data source=localhost");
              conn.Open();
              SqlCommand cmd = conn.CreateCommand();
              cmd.CommandText = "SELECT * FROM Tabel WHERE tels_no = '"+textbox1.Text.Replace("'","")+"'";
              SqlDataReader reader = cmd.ExecuteReader();
              while(reader.Read())
              {
              TextBox2.Text = reader["tels_name"].ToString();
              }

              Use following namespaces: using System.Data; using System.Data.SqlClient;

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

              ARGH!! Never build SQL queries concatenating strings! Have you never heard of SQL injection attacks?

              B 2 Replies Last reply
              0
              • M Mohamed El Wehishy

                hi guys i have table in sqlserver database named tels has columns tels_no , tels_name , tels_cost ok i want to enter a no in a textbox in the application then auto it get data of this no and set this in two different textboxes one for tels_name and other for tels_cost how?????????? i do not know thanks, Mohamed El-Wehishy

                H Offline
                H Offline
                Henry Minute
                wrote on last edited by
                #8

                Please, please, purrrrleeees stop using "I need help" for every topic line. Use something like "Problem retrieving data", or similar. Errm...., obviously not if it's a Graphics question but you know what I mean. :)

                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                1 Reply Last reply
                0
                • M Mirko1980

                  ARGH!! Never build SQL queries concatenating strings! Have you never heard of SQL injection attacks?

                  B Offline
                  B Offline
                  Blikkies
                  wrote on last edited by
                  #9

                  This is an example code, not code that im using. instead of Preaching to me, Give this guy a solution or back off.

                  1 Reply Last reply
                  0
                  • M Mirko1980

                    ARGH!! Never build SQL queries concatenating strings! Have you never heard of SQL injection attacks?

                    B Offline
                    B Offline
                    Blikkies
                    wrote on last edited by
                    #10

                    Secondly i USED REPLACE IN THE QUERY

                    C 1 Reply Last reply
                    0
                    • B Blikkies

                      Secondly i USED REPLACE IN THE QUERY

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

                      1 - your code does NOT stop injection attacks 2 - if you give people here code, they are likely to use it verbatim, not ever understand it 3 - why give people examples they shouldn't use ?

                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                      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