|
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&) |
<%@ 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>
