Hi,

I've an asp.net web application that shows, through an odbc connection to a
mysql database, the content of the table chosen from a DropDownList.
The code go well on windows but on linux with mono 1.01 not all the tables are
shown correctly.

I've also tried to run a c# example that makes the same thing and it works
well....so I think that is not a problem of mysql or odbc connection, but
rather it may be a problem of odbcDataAdapter or Data set....

Is it true?
Could anybody help me?

asp.net web application: WebForm1VisuaTabelle.aspx,
WebForm1VisuaTabelle.aspx.cs
c# example: ProvaVisuaTabella.cs

Thanks a lot,

Valentina.

Attachment: WebForm1VisuaTabelle.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 VisuaTabelle
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			Tabella = DropDownList1.SelectedItem.Text;
		}

		protected System.Web.UI.WebControls.Button ButtonRicerca;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.Button Button1;

		string Tabella = null;
		#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.ButtonRicerca.Click += new System.EventHandler(this.ButtonRicerca_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ButtonRicerca_Click(object sender, System.EventArgs e)
		{
			Label2.Text = "Tabella "+ Tabella;
			//OdbcConnection conn = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=tdmio;"+"UID=root;"+"PASSWORD=rootpwd;");
			OdbcConnection conn = new OdbcConnection ("DRIVER=MySQL;SERVER=localhost;DATABASE=tdmio;UID=root;PASSWORD=rootpwd;");
			OdbcDataAdapter daTabella = new OdbcDataAdapter("select * from " +Tabella + "", conn);
			DataSet Ds = new DataSet();
			conn.Open();
			daTabella.Fill(Ds, Tabella);
			conn.Close();
			DataGrid1.DataSource= Ds;
			DataGrid1.DataBind();
		}
	}
}
using System;
using System.Data.Odbc;

namespace ProvaVisuaTabelle
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			Console.WriteLine("Inserisci il nome della tabella: ");
			string nome = Console.ReadLine();
			//OdbcConnection conn = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=tdmio;"+"UID=root;"+"PASSWORD=rootpwd;");
			OdbcConnection conn = new OdbcConnection ("DRIVER=MySQL;SERVER=localhost;DATABASE=tdmio;UID=root;PASSWORD=rootpwd");
			conn.Open();
			OdbcCommand com = new OdbcCommand();
			com = conn.CreateCommand();
			com.CommandText="Select * from " +nome+ "";
			OdbcDataReader dbReader =null;
			dbReader = com.ExecuteReader();
			Console.WriteLine();
			for (int i=0; i<dbReader.FieldCount;i++)
			{
				Console.Write("{0}",dbReader.GetName(i).PadLeft(10,' '));
			}
			Console.WriteLine();
			while (dbReader.Read())
			{
				for (int j=0;j<dbReader.FieldCount;j++)
				{
					//valore = (string)dbReader.GetValue(j);
					Console.Write("{0}", dbReader.GetValue(j).ToString().PadRight(20,' '));
				}
				Console.WriteLine();
			}

			
			dbReader.Close();
			conn.Close();
		}
	}
}

Reply via email to