在monotools中使用odbc时出错500?

时间:2011-03-15 00:23:59

标签: c# asp.net mono monodevelop

嗨我在单声道工具中运行此代码时遇到错误?

不确定如何解决?

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Login1.Authenticate += Login1_Authenticate;
    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite; User=root; Password=commando; OPTION=3;");
        cn.Open();
        OdbcCommand cmd = new OdbcCommand("Select * from login where username=? and password=?", cn);

        //Add parameters to get the username and password  

        cmd.Parameters.Add("@username", OdbcType.VarChar);
        cmd.Parameters["@username"].Value = this.Login1.UserName;

        cmd.Parameters.Add("@password", OdbcType.VarChar);
        cmd.Parameters["@password"].Value = this.Login1.Password;

        OdbcDataReader dr = default(OdbcDataReader);
        // Initialise a reader to read the rows from the login table.  
        // If row exists, the login is successful  

        dr = cmd.ExecuteReader();

        if (dr.HasRows)
        {
            e.Authenticated = true;
            Response.Redirect("UserProfileWall.aspx");
            // Event Authenticate is true  
        }

    }
}

ystem.NotImplementedException:未实现请求的功能。错误500 enter image description here

1 个答案:

答案 0 :(得分:1)

HasRows没有实现,但我认为一个简单的解决方法就是:

if (dr.Read ()) {
...
}
相关问题