[Mono-list] ASP.NET + ByteFX.Data

David La Motta dlamotta@email.com
Thu, 09 Oct 2003 23:05:04 -0400


This is a multi-part message in MIME format.
--------------080907030808040309070604
Content-Type: multipart/alternative;
 boundary="------------010703070601080305020406"


--------------010703070601080305020406
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello all.

I am running xsp 0.6 and I am trying to do some simple playing around to 
see if I can get some data out of MySql.  I downloaded the latest 
ByteFX.Data assembly and was able to run a very simple query from the 
command line--joy!  I then proceeded to modify the dbpage1.aspx example 
provided with mod_mono and replaced the PostgreSql directives with MySql 
ones.  I seemed to get around syntactical mistakes but now the server 
responds with the following.  I am attaching the .aspx file in case any 
of you is feeling good enough to take a look  :-)  I added the 
ByteFX.Data.dll and SharpZipLib.dll to my /usr/lib directory and 
restarted the xsp server.  Not sure what to try next. 

Thanks for any help!

// David

*Description: *Error processing request.

*Error Message: *

*Stack Trace: * ||

System.IO.FileNotFoundException: File 'ByteFX.Data.MySqlClient' not found.
in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x20) [0x400a98e9]
in (unmanaged) /usr/lib/libmono.so.0 [0x400cb5c7]
in <0x0006c> (wrapper remoting-invoke-with-check) System.AppDomain:LoadAssembly (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in <0x00044> System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in <0x0006b> (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in <0x00074> System.AppDomain:Load (string)
in <0x00058> (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
in <0x0001c> System.Reflection.Assembly:Load (string)
in <0x00045> ASP.mysql_aspx:Page_Init (object,System.EventArgs)
in <0x0005a> (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)
in <0x00090> System.Web.UI.Control:OnInit (System.EventArgs)
in <0x0020d> System.Web.UI.Control:InitRecursive (System.Web.UI.Control)
in <0x00047> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext)
in <0x00191> .ExecuteHandlerState:Execute ()
in <0x0004e> .StateMachine:ExecuteState (System.Web.HttpApplication/IStateHandler,bool&)



--------------010703070601080305020406
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Hello all.<br>
<br>
I am running xsp 0.6 and I am trying to do some simple playing around
to see if I can get some data out of MySql.&nbsp; I downloaded the latest
ByteFX.Data assembly and was able to run a very simple query from the
command line--joy!&nbsp; I then proceeded to modify the dbpage1.aspx example
provided with mod_mono and replaced the PostgreSql directives with
MySql ones.&nbsp; I seemed to get around syntactical mistakes but now the
server responds with the following.&nbsp; I am attaching the .aspx file in
case any of you is feeling good enough to take a look&nbsp; :-)&nbsp; I added the
ByteFX.Data.dll and SharpZipLib.dll to my /usr/lib directory and
restarted the xsp server.&nbsp; Not sure what to try next.&nbsp; <br>
<br>
Thanks for any help!<br>
<br>
// David<br>
<br>
<b>Description: </b>Error processing request.
<p><b>Error Message: </b>
</p>
<b>Stack Trace: </b>
<code></code>
<pre>System.IO.FileNotFoundException: File 'ByteFX.Data.MySqlClient' not found.
in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x20) [0x400a98e9]
in (unmanaged) /usr/lib/libmono.so.0 [0x400cb5c7]
in &lt;0x0006c&gt; (wrapper remoting-invoke-with-check) System.AppDomain:LoadAssembly (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in &lt;0x00044&gt; System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in &lt;0x0006b&gt; (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in &lt;0x00074&gt; System.AppDomain:Load (string)
in &lt;0x00058&gt; (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
in &lt;0x0001c&gt; System.Reflection.Assembly:Load (string)
in &lt;0x00045&gt; ASP.mysql_aspx:Page_Init (object,System.EventArgs)
in &lt;0x0005a&gt; (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)
in &lt;0x00090&gt; System.Web.UI.Control:OnInit (System.EventArgs)
in &lt;0x0020d&gt; System.Web.UI.Control:InitRecursive (System.Web.UI.Control)
in &lt;0x00047&gt; System.Web.UI.Page:ProcessRequest (System.Web.HttpContext)
in &lt;0x00191&gt; .ExecuteHandlerState:Execute ()
in &lt;0x0004e&gt; .StateMachine:ExecuteState (System.Web.HttpApplication/IStateHandler,bool&amp;)
</pre>
<br>
</body>
</html>

--------------010703070601080305020406--

--------------080907030808040309070604
Content-Type: text/plain;
 name="mysql.aspx"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mysql.aspx"

<%@ language="C#" %>
<%@ import namespace="System.Configuration" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Reflection" %>

<html>
<script runat=server>

	static Type cncType = null;

	void ShowError (Exception exc)
	{
		noDBLine.InnerHtml += "<p><b>The error was:</b>\n<pre> " + exc + "</pre><p>";
		theForm.Visible = false;
	}

	IDbConnection connection;
	void Page_Init (object sender, EventArgs e)
	{
        string providerAssemblyName = "ByteFX.Data.MySqlClient";
        string connectionTypeName = "ByteFX.Data.MySqlClient.MySqlConnection";
		string connectionString = "Server=127.0.0.1;User ID=mono;Password=;Database=test";

        Assembly dbAssembly = Assembly.Load (providerAssemblyName);
		cncType = dbAssembly.GetType (connectionTypeName, true);

		if (!typeof (IDbConnection).IsAssignableFrom (cncType))
		 	 throw new ApplicationException ("The type '" + cncType +
								"' does not implement IDbConnection.\n" +
								"Check 'DbConnectionType' in server.exe.config.");

		connection = (IDbConnection) Activator.CreateInstance (cncType);
		connection.ConnectionString = connectionString;

        try {
            connection.Open();
        } catch (Exception exception) {
			ShowError (exception);
			connection = null;
        }       	  
	}

	void Page_Load (object sender, EventArgs e)
	{
		if (!IsPostBack){
			FirstNameFilter.Text = "%";
			LastNameFilter.Text = "%";
			UpdateTable (FirstNameFilter.Text, LastNameFilter.Text);
		}
	}

	void Filter_Changed (object sender, EventArgs e)
	{
		UpdateTable (FirstNameFilter.Text, LastNameFilter.Text);
	}

	void UpdateTable (string firstName, string lastName)
	{
		if (connection == null)
			return;

		IDbCommand selectCommand = connection.CreateCommand();

        string sql = "SELECT firstname, lastname FROM employees";
		selectCommand.CommandText = sql;

		IDataReader reader;

		try {
			reader = selectCommand.ExecuteReader ();
			while (reader.Read ()) {
				TableRow row = new TableRow ();
				for (int i = 0; i < reader.FieldCount; i++) {
					TableCell cell = new TableCell ();
					cell.Controls.Add (new LiteralControl (reader.GetValue (i).ToString ()));
					row.Cells.Add (cell);
				}
				myTable.Rows.Add (row);
			}
		} catch (Exception exc) {
			ShowError (exc);
		}
	}

</script>
<head>
<title>MySQL testing</title>
</head>
<body>

<span runat="server" visible="false" id="noDBLine">
<h3>Database Error</h3>
</span>

<form id="theForm" runat="server">
Choose the SQL filters and click 'Submit'.
<asp:Label Text="First Name: " />
<asp:TextBox id="FirstNameFilter" Text="" TextMode="singleLine" OnTextChanged="Filter_Changed" runat="server" maxlength=40 />
<p>
<asp:Label Text="Last Name: " />
<asp:TextBox id="LastNameFilter" Text="" TextMode="singleLine" OnTextChanged="Filter_Changed" runat="server" maxlength=40 />
<p>
<asp:Button id="btn" runat="server" Text="Submit" />
<p>
<asp:Table id="myTable" HorizontalAlign="Left" Font-Size="12pt" GridLines="both" 
CellPadding="5" runat="server"/>
</form>
</body>
</html>


--------------080907030808040309070604--