View Single Post
Old Apr 6th, 2007, 7:25 PM   #1
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Exclamation critical: pls help: MySql Database with ASP.NET and C#

I installed the MySql driver, and was able to insert into the database just fine from my code behind file, but when i try to use the MySqlDataReader,, i get an error that it cannot be found:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;




    public partial class _Default : System.Web.UI.Page
    {
        MySqlConnection mysqlcon;


        protected void Page_Load(object sender, EventArgs e)
        {
            Application["auth"] = false;
            
            String con = "";
            con = "server=localhost; user id=root; password=test; database=cs;";
            mysqlcon = new MySqlConnection(con);
            mysqlcon.Open();
        }
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void login_Click(object sender, EventArgs e)
       {
           string formPassword = Request.Form["password"];
            
        string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(formPassword, "sha1");
        string dbPassword = "";
        string dbUser = "";
        
        
        MySqlCommand cmd = mysqlcon.CreateCommand();
        MySqlDataReader recordset = mysqlcon.ExecuteReader();

        cmd.CommandText = "SELECT userid, password from auth where password = '" + hashedPassword + "'";

        recordset = cmd.EndExecuteReader();

        while (recordset.Read())
        {
            dbUser = recordset.GetString(0);
            dbPassword = recordset.GetString(1);
        }

        if (Request.Form["userid"] == dbUser && hashedPassword == dbPassword)
        {
            Application["auth"]=true;
            Response.Redirect("enterInv.aspx");
        }



    }
 }


The errors say:

Error 1 'MySql.Data.MySqlClient.MySqlConnection' does not contain a definition for 'ExecuteReader' C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\Projects\ASP\final_assignment\Default.aspx.cs 44 46 C:\...\final_assignment\


Error 2 No overload for method 'EndExecuteReader' takes '0' arguments C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\Projects\ASP\final_assignment\Default.aspx.cs 48 21 C:\...\final_assignment\
paulchwd is offline   Reply With Quote