Hi, I try to run dbReader.aspx page but I obtein this error: ------------------------------ Server error in '/mono' application Description: Error processing request.
Error Message: HTTP 500. Stack Trace: System.IndexOutOfRangeException: Array index is out of range. in <0x000d5> System.Data.Odbc.OdbcDataReader:GetValue (int) in <0x0005d> (wrapper remoting-invoke-with-check) System.Data.Odbc.OdbcDataReader:GetValue (int) in <0x00012> System.Data.Odbc.OdbcDataReader:get_Item (int) in <0x0005d> (wrapper remoting-invoke-with-check) System.Data.Odbc.OdbcDataReader:get_Item (int) in <0x0016d> dbReaderASP.WebForm1:Button1_Click (object,System.EventArgs) in <0x0006a> (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs) in <0x00090> System.Web.UI.WebControls.Button:OnClick (System.EventArgs) in <0x00058> System.Web.UI.WebControls.Button:System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (string) in <0x00016> System.Web.UI.Page:RaisePostBackEvent (System.Web.UI.IPostBackEventHandler,string) in <0x0003a> System.Web.UI.Page:RaisePostBackEvents () in <0x002ab> System.Web.UI.Page:InternalProcessRequest () in <0x000c2> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext) in <0x002e8> ExecuteHandlerState:Execute () in <0x00084> StateMachine:ExecuteState (System.Web.HttpApplication/IStateHandler,bool&) ----------------------------------------- What could I do? I think the c# code is correct becouse it runs on windows.... could it be a problem of mono..? I've mono 1 beta with fedora core 2. Which version have you? Do you obtain the same error? Thanks, Valentina.
WebForm1dbReader.aspx
Description: Binary data
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
namespace dbReaderASP
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label2;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
Label3.Text="";
Session.Add("Login", TextBox1.Text);
object LoginIns = Session["Login"];
//OdbcConnection conn = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=Login;"+"UID=root;"+"PASSWORD=rootpwd;");
OdbcConnection conn = new OdbcConnection("DRIVER=MySQL;SERVER=localhost;DATABASE=login;UID=root;PASSWORD=rootpwd;");
OdbcDataReader dbReader = null;
conn.Open();
OdbcCommand cmd = conn.CreateCommand();
cmd.CommandText = "Select RuoloAziendale from login where Login='"+ LoginIns +"'";
dbReader = cmd.ExecuteReader();
if (dbReader.Read())
{
//Label3.Text=((string)dbReader["RuoloAziendale"]);
//Label3.Text=dbReader["RuoloAziendale"].ToString();
Label3.Text=dbReader[2].ToString();
}
else
{
Label3.Text=("login errata!");
}
Session.RemoveAll();
dbReader.Close();
conn.Close();
}
}
}
