CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Red face C# and MySql .Net Connector...and simple Mysql Login?

    MySQL .Net connector is a great way to integrate my MySQL databases with my VB and C# web applications in Visual Studio 2010.

    Although I am fairly new to using this intermediate there are wonderful resources that explain how to use the MySQL Website Configuration Tool to manage authentication. After installation (http://dev.mysql.com/downloads/connector/net/) I find the configuration tool located in the Solution Explorer to allow authentication customization. Although this is a wonderful resource I am faced with a challenge.

    I need to create another login system inside the primary application that queries a specific table (Group managers)and checks >1

    I'm already using the MySQL Website Configuration Tool provided by MySQL .Net connector to manage accounts and profiles created in the MySQL database to manage authentication

    My second login only needs to evaluate the table (Group Managers)and check >1

    So basically, does anyone know of a tut that will explain to me how to create a simple MySQL login in C# ASP.NET in Visual Studio 2010 that checks a MySQL table(Group Managers) "|id|usename|password|" and checks >1???

    Thank you

    Charlie

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: C# and MySql .Net Connector...and simple Mysql Login?

    Welcome to the FORUMS!

    SQL Statements can connect to any data source, but you'd need to know it, the table name, the field name(s)/sequence, etc.

    Can you open the source table any other way?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2011
    Posts
    2

    Re: C# and MySql .Net Connector...and simple Mysql Login?

    I do agree, I am under the understanding that Connector/Net is a fully managed ADO.NET driver for MySQL. Which is awesome! So I guess perhaps I am wondering if I could be pointed to a resource that would give me some direction...

    1)Install Connector

    2) New C# Web application

    3) Go to Server explorer, and connect to new DB

    4)Select Data Source and Creds

    5)New Web Form

    7)Drag in a Login component from the toolbox into design view

    8)Double click the login control

    9) And.......This does not work. (But web applications don't use a resource folder)
    Im just a little lost

    public bool tryLogin(string username,string password)
    {
    MySqlConnection con = new MySqlConnection("host=localhost;usr=root;password=mypassword;db=mydatabase;");
    MySqlCommand cmd = new MySqlCommand("SELECT * FROM users WHERE username = '" + username + "' AND mypass = '" + password + "';");
    cmd.Connection = con;
    con.Open();
    MySqlDataReader reader = cmd.ExecuteReader();
    while (reader.Read())
    {
    if(reader.GetString(0) != 1)
    { return false; }
    else
    { return true; }
    }
    cmd.Connection.Close();
    reader.Dispose();
    cmd.Dispose();
    }
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured