Web Analytics Made Easy -
StatCounter Getting Information from MySQL using C# - CodingForum

Announcement

Collapse
No announcement yet.

Getting Information from MySQL using C#

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Information from MySQL using C#

    Let me start off with my question: How can I retrieve a value from a column in a row given the first column's value?

    I am trying to get a value from my MySQL server based on the first column's data.

    Here is the mySQL data:
    Click image for larger version

Name:	2016-09-19 18_51_19-swghuttcartel.com _ localhost _ tcg _ users _ phpMyAdmin 4.6.3.png
Views:	1
Size:	15.5 KB
ID:	2283615

    For example, if I had the Username value "admin" how would I be able to get the "level" column data from that same row?

    As you can see, I have a mySQL adapter in Visual Studio that's called Level, which will help get the level value.
    Click image for larger version

Name:	2016-09-19 18_47_43-Trading Card Game - Microsoft Visual Studio.png
Views:	1
Size:	12.7 KB
ID:	2283616
    In it I have:
    Code:
    select *from users where level = @level
    I know that is wrong and I am wondering what to change this to as well.

    Thank you for your help
    Iosnowore

  • #2
    Code:
    Select level from users where username = 'admin';

    Comment


    • #3
      Originally posted by FishMonger View Post
      Code:
      Select level from users where username = 'admin';
      Oh thank you! Do you know the C# part of the code to use?

      Comment


      • #4
        Sorry, I don't code in C#

        Comment


        • #5
          Originally posted by FishMonger View Post
          Sorry, I don't code in C#
          Okay no problem! I found it out. :P
          And one more question please if you have the time to answer, how would you replace data, like if I wanted to replace the password for the user admin?

          Comment


          • #6
            Use an update statement instead of a select statement.

            Comment


            • #7
              Originally posted by FishMonger View Post
              Use an update statement instead of a select statement.
              Hmm, I looked through that guide and I came up with
              Code:
              update users set admin = Iosnowore where username = 'admin'
              and I got the error
              Code:
              Additional information: Unknown column 'admin' in 'field list'

              Comment


              • #8
                Change admin to the name of your password field.
                Dave .... HostMonster for all of your hosting needs

                Comment

                Working...
                X