Hi,
I've a web service example, called Service1.asmx, that contains four methods.
The example works well on Windows, but when I try to execute it on Mono I have
some problems , particularly when I invoke the "SessioneAttiva" method,  I
obtain this error:

"The remote server returned an error: (500) Internal Server Error.
Unable to retreive error information from ODBC driver manager"

What it means?

Please help me.

I've Fedora Core 2, Mono 1.01 and I use a mysql database (4.1.3-beta-standard)
via unixOdbc (2.2.8).


Thanks,

Valentina.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.Odbc;

namespace ServiceTdProva
{
	
	public class Service1 : System.Web.Services.WebService
	{
		public Service1()
		{
			InitializeComponent();
		}

		#region Component Designer generated code
		
	
		private IContainer components = null;
		
		private void InitializeComponent()
		{
		}

		protected override void Dispose( bool disposing )
		{
			if(disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);		
		}
		
		#endregion

		
		
		string DataOdierna=DateTime.Today.Year.ToString() +"-"+ DateTime.Today.Month.ToString() +"-"+ DateTime.Today.Day.ToString();

		public string CatchProblema()
		{	
			string problema="0";
			//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;");
			OdbcDataReader dbReader = null;
			conn.Open();
			OdbcCommand cmd = conn.CreateCommand();
			cmd.CommandText = "Select  CodiceProblema from problemi where Data='"+DataOdierna+"'"; 
			dbReader = cmd.ExecuteReader();
			while(dbReader.Read())
			{
				problema =(string)dbReader["CodiceProblema"];
			}
			dbReader.Close();
			conn.Close();

			return problema;
		}

		[WebMethod (EnableSession=true)]
		public string LogIn(string UserIdInput, string PasswordInput)
		{
			//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;");
			OdbcDataReader dbReader = null;
			conn.Open();
			OdbcCommand cmd = conn.CreateCommand();
			cmd.CommandText = "Select * from utenti where UserID='"+UserIdInput+"' and Password='"+PasswordInput+"'"; 
			dbReader = cmd.ExecuteReader();
			if(dbReader.Read())
			{	
				string Gruppo = (string)dbReader["Gruppo"];
				string Utente = (string)dbReader["CodiceUtente"];
				Session.Add("Utente",Utente);
				Session.Add("Gruppo",Gruppo);
				dbReader.Close();
				conn.Close();	
				return (string)Session["Gruppo"]; 
			}
			else
			{	
				dbReader.Close();
				conn.Close();	
				return "Errore";		
			}							
		}
		/*######################################################################################################*/
		
		[WebMethod (EnableSession=true)]
		public void LogOut()
		{	
			Session.RemoveAll();
		}
		/*######################################################################################################*/
		
		[WebMethod (EnableSession=true)]
		public string NuovaSessione()
		{			
			string problema = CatchProblema();
			int massimo=0;
			//Se l'utente �stato indentificato ed �un pianificatore allora pu�aprire una nuova sessione
			if ((Session["Utente"]!= null)&((string)Session["Gruppo"]=="G1"))
			{	
				//controllo che l'utente non abbia gi�una sessione attiva
				//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;");
				OdbcDataReader dbReader = null;
				conn.Open();
				OdbcCommand cmd = conn.CreateCommand();
				cmd.CommandText = "Select * from sessione where Utente ='"+(string)Session["Utente"]+"'and Stato='Attiva'";
				dbReader = cmd.ExecuteReader();
				if(dbReader.Read())
				{
					//si allora comunico l'errore perch�non possono essere contemporaneamente attive 2 sessioni
					string stringa="l'utente" +(string)Session["Utente"]+ "ha gi�una sessione attiva, non �possibile aprirne altre!";
					dbReader.Close();
					conn.Close();
					return stringa;
				}
				else
				{
					//no allora apro una nuova sessione
					dbReader.Close();
					conn.Close();
					OdbcConnection con =null;
					OdbcConnection connessione=null; 
					//con = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=tdmio;"+"UID=root;"+"PASSWORD=rootpwd;");
					con = new OdbcConnection ("DRIVER=MySQL;SERVER=localhost;DATABASE=tdmio;UID=root;PASSWORD=rootpwd;");
					con.Open();
					OdbcCommand command = con.CreateCommand();
					OdbcCommand commandSessione = con.CreateCommand();
					commandSessione.CommandText= "select * from sessione where CodiceSessione=1";
					dbReader= commandSessione.ExecuteReader();
					if (dbReader.Read())
					{
						dbReader.Close();
						//recupero il codice dell'ultima sessione
						command.CommandText = "Select max(CodiceSessione)as CodiceSessione from sessione";
						dbReader = command.ExecuteReader();
				
						while(dbReader.Read())
						{
							massimo = (int)dbReader["CodiceSessione"];
						}
						
						dbReader.Close();
						con.Close();
					}
						//�la prima tupla della tabella non esiste massimo
					else massimo=0;
					con.Close();
					try
					{	
						object Sessione;
						Sessione=massimo+1;
						Session["Sessione"]=Sessione ;
						//ed inserisco la tupla per la nuova sessione
						//connessione = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=tdmio;"+"UID=root;"+"PASSWORD=rootpwd;");
						connessione = new OdbcConnection ("DRIVER=MySQL;SERVER=localhost;DATABASE=tdmio;UID=root;PASSWORD=rootpwd;");
						connessione.Open();
						OdbcCommand comd = new OdbcCommand("Insert into sessione (CodiceSessione, Problema, Stato, Utente) values ('"+(int)Session["Sessione"]+"','"+problema+"','Attiva','"+(string)Session["Utente"]+"')", connessione);
						comd.ExecuteNonQuery();
					}
					catch (OdbcException odbe)
					{
						return odbe.Message;
					}
					finally
					{
						if (connessione!=null)
						{
							connessione.Close();
						}
						
					}
					return "SI";
					//l'utente ha aperto una nuova sessione quindi ritorno "Si"
				}
			}
			else return "NO";	
			//l'utente non pu�accedere a quest'area allora torno "no"
		}
		/*################################################################################################*/
		//3)Visualizza la sessione attiva
		[WebMethod (EnableSession=true)]
		public DataSet SessioneAttiva()
		{
			string query = "select* from sessione where Utente = '"+(string)Session["Utente"]+"' and Stato='Attiva'";
			//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;");
			OdbcDataReader dbReader = null;
			OdbcCommand comd = new OdbcCommand(query, conn);
			conn.Open();
			dbReader = comd.ExecuteReader();
			//se non c'�una sessione attiva dell'utente connesso
			if(!dbReader.Read())
			{
				conn.Close();
				DataSet Ds = new DataSet();
				//visualizzo una stringa
				//OdbcConnection con = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=Login;"+"UID=root;"+"PASSWORD=rootpwd;");
				OdbcConnection con = new OdbcConnection ("DRIVER=MySQL;SERVER=localhost;DATABASE=login;UID=root;PASSWORD=rootpwd;");
				OdbcDataAdapter ErTabella = new OdbcDataAdapter("select * from errore where IdErrore= 'E3'", con);
				conn.Open();
				ErTabella.Fill(Ds);
				con.Close();
				return Ds;					
			}
			else
			{
				//atltrimenti visualizza la sessione attiva
				conn.Close();
				//OdbcConnection con = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};"+"SERVER=localhost;"+"DATABASE=tdmio;"+"UID=root;"+"PASSWORD=rootpwd;");
				OdbcConnection con = new OdbcConnection ("DRIVER=MySQL;SERVER=localhost;DATABASE=tdmio;UID=root;PASSWORD=rootpwd;");
				DataSet Ds = new DataSet();
				OdbcDataAdapter daTabella = new OdbcDataAdapter(query, conn);
				daTabella.Fill(Ds, "sessione");
				dbReader.Close();
				con.Close();
				return Ds;
			}													
								
		}
	}
}

Attachment: Service1.asmx
Description: Binary data

Reply via email to