HowTo Connect MONO ASP.NET with PostgreSql on linux

Well, actually this is pretty easy after you already have commited 101 errors :s
Anyway, I used my home Slackware 10.2 and installed on it MONO Ver. 1.1.16.1, you can get the installer here.
Here are the steps:
* Install it on /opt/mono
* Run the XSP Server from the command line: /opt/mono/bin/xsp2 --root /opt/mono/apps --port 8080
* Edit an index.aspx.cs file on /opt/mono/apps:
// created on 8/20/2006 at 6:38 PM using System; using System.Web; using System.Data; using Npgsql; public partial class index_aspx : System.Web.UI.Page { public void DisplayEmployees() { string connectionString= "Server=<you_host>;" + "Database=<your_database>;" + "User ID=<your_user>;" + "Password=<your_password>;"; NpgsqlConnection conn=new NpgsqlConnection(connectionString); conn.Open(); NpgsqlCommand command=new NpgsqlCommand("SELECT <field1>,<field2> FROM <your_table>",conn); NpgsqlDataReader dr=command.ExecuteReader(); Response.Write("FIELD1 Title:\t"); Response.Write("FIELD2 Title:\t\n"); while(dr.Read()) { Response.Write(dr[0]+ ":"); Response.Write(dr[1]+ "<br>"); } conn.Close(); } private void Page_Load(object sender, EventArgs e) { this.DisplayEmployees(); Page.DataBind(); } } Then, simple edit your front end web page index.aspx: <%@ Page language="C#" CodeFile="index.aspx.cs" Inherits="index_aspx"%> <%@ import Namespace="Npgsql"%> <%@ Assembly Name="Npgsql"%> <html> <head> <title>This is my pretty cool asp.net page test for mono+pgsql</title> <style> body,td{ font-family:Bitstream Vera Sans,Verdana,Sans; font-size:10px; } </style> </head> <body> <center>Just Testing..!</center> This are the records of my database:

Voilá hope this helps you, try restarting your xsp server after the editing on this pages...

any comment or hint esanchez [at] gruponumar.com