How can I display MySQL database table user info in c sharp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aviator4Life
    New Member
    • Aug 2012
    • 3

    How can I display MySQL database table user info in c sharp

    Hi all

    I am a new c sharp programmer and I was looking at this code:

    Code:
    private void button1_Click(object sender, EventArgs e)
    {
    string input = textBox3.Text;
    connectdatabase();
    string wow = "SELECT `CustomerName` FROM `CustomerInfo`";
    MySqlCommand wowcmd = new MySqlCommand(wow, connection);
    MySqlDataReader Reader;
    Reader = wowcmd.ExecuteReader();
    while (Reader.Read())
    {
    if (input == Convert.ToString(Reader))
    {
    textBox5.Text = Convert.ToString(Reader);
    }
    }
    
    
    }
    Post Reply
    And I was wondering if anyone could rewrite the code so that it display the MySQL table data for a specific user I already have a string called username and that stores the username entered on the login form. I want the code to use the username string to search for the name and display that users info.

    My table contents are: username
    First name
    Last name
    Position
    Employee Id
    Airline

    If you do this it would be greatly appreciated
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    Sorry but this isnt a code writing repository, so we're not going to rewrite your code

    Comment

    • Aviator4Life
      New Member
      • Aug 2012
      • 3

      #3
      Can you at least tell me what too do

      Comment

      • Grim
        New Member
        • Aug 2012
        • 2

        #4
        There is an example in MySQL Conenctor .Net, just look at it.

        Comment

        • PsychoCoder
          Recognized Expert Contributor
          • Jul 2010
          • 465

          #5
          The only thing you need to do is to change your query. So change this

          Code:
          string wow = "SELECT `CustomerName` FROM `CustomerInfo`";
          to this

          Code:
          string wow = "SELECT `CustomerName` FROM `CustomerInfo` where <Your Column> = <YourVariable>";
          What you've done there is tell it to return everything for a certain user. Hope that helps.

          Happy Coding!

          Comment

          • ariful alam
            New Member
            • Jan 2011
            • 185

            #6
            Code:
            select `first_name` + ' ' + `last_name` from `<table_name>` where username = <your variable name>

            Comment

            • Aviator4Life
              New Member
              • Aug 2012
              • 3

              #7
              Thank you all for the help greatly appreciated guess I'm sticking with this for cause daniweb takes weeks to reply

              Comment

              • PsychoCoder
                Recognized Expert Contributor
                • Jul 2010
                • 465

                #8
                Glad we could help you with this.

                Comment

                Working...