Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:12:33+00:00 2026-06-13T00:12:33+00:00

i am using C# and i need to develop a check system for a

  • 0

i am using C# and i need to develop a check system for a mysql user and password.
So far what ive come up with is this and the error i get is that it is the wrong syntax…

public bool VerifyUser(string username, string password)
{
    string returnValue = "";

    string Query = "SELECT Pass FROM Base_Character WHERE User='" + username + "'";

    MySqlCommand verifyUser = new MySqlCommand(Query, this.sqlConn);

    try
    {
        verifyUser.ExecuteNonQuery();

        MySqlDataReader myReader = verifyUser.ExecuteReader();

        while (myReader.Read() != false)
        {
            returnValue = myReader.GetString(0);
        }

        myReader.Close();
    }
    catch (Exception excp)
    {
        Exception myExcp = new Exception("Could not verify user. Error: " +
            excp.Message, excp);
        throw (myExcp);
    }

    if (returnValue == password)
    {
        return false;
    }
    else
    {
        return true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:12:35+00:00Added an answer on June 13, 2026 at 12:12 am

    ExecuteNonQuery is for DELETE, INSERT and UPDATE. Whenever you want data returned as rows from database, use ExecuteReader

    Your query should check the username and password together, if they exist in one record then the row is returned else nothing is returned.

    You still need more to learn about coding/database programming using .Net

    public bool VerifyUser(string username, string password)
    {
        bool returnValue = false;
        string Query = "SELECT 1 FROM Base_Character WHERE User='" + username + "' AND pass='"+password+"'";
    
        try
        {
            MySqlCommand command = new MySqlCommand(Query, this.sqlConn);
    
            MySqlDataReader myReader = command.ExecuteReader();
    
            if(myReader.Read())
            {
                returnValue = true;
            }
    
            myReader.Close();
        }
        catch (Exception excp)
        {
            throw;
        }
    
        return returnValue;
     }
    

    You should probably not throw a custom exception since you are using boolean

    if(VerifyUser("user123", "******"))
    {
       //Congratulations
    }
    else
    {
       //Unable to log you in
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to develop this kind of application, i'm using php and mysql first
I need to develop an app that is using multithreading. Basicly, I have a
I need to develop an evaluation tool using C# that will run on the
I need to develop simple game that will be using peer to peer connection
I need to develop an application that connects to various DSN's using the Microsoft
I need to develop a mobile app that is capable of using the device's
I need to develop an application that will periodically check data from a XML
I need to develop web application using ASP.net with C# to handle mysql database
I need to develop a web site where I upload videos using the youtube
I need some advice from experts :) I will develop a website using PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.