Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   ASP.NET (http://www.programmingforums.org/forum35.html)
-   -   critical: pls help: MySql Database with ASP.NET and C# (http://www.programmingforums.org/showthread.php?t=12946)

paulchwd Apr 6th, 2007 7:25 PM

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\

Ghost Apr 16th, 2007 3:51 AM

Did you get this error worked out?


All times are GMT -5. The time now is 9:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC