[Mono-list] Xsp + Postgres error!

ccesario ccesario@isic.com.br
Sat, 21 Sep 2002 21:56:53 +0000


Hey friends,
   I'm trying to do a test using xsp + postgres and I ain't getting any 
results.
   I already tried several ways of doing it, mono doesn't show any errors, 
but I can't see any results either. I have the following table in Postgres: 

   Aluno
      id   int8
      nome varchar(30)
      nota float 

I tried the following code snippets: 

 ----------------------------------- 

<%@ Page Language="C#"  Debug="true" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>
<html>
<script runat="server" language="c#"> 

void Page_Load (object sender, EventArgs e)
{
   Response.Write("Holy crap");
   SqlConnection cnc = new SqlConnection();
   cnc.ConnectionString = "Data Source=200.206.158.45:5432;User 
ID=ziral;Password=ziral;Initial Catalog=teste;";
   cnc.Open ();
   string selectCmd = "SELECT * FROM aluno";
   SqlCommand selectCommand = cnc.CreateCommand();
   selectCommand.CommandText = selectCmd;
   SqlDataReader reader = selectCommand.ExecuteReader();
   while (reader.Read ()) {
       Response.Write (reader.GetString(0) + ", " + reader.GetString(1));
   }
   reader.Close();
   cnc.Close();
} 

</script> 

<head>
<title>Some DB testing</title>
</head>
<body>
<form runat=server>
<asp:label id="lbl1" Text="No changed" runat="server"/>
</form>
</body>
</html> 

 ------------------------------------------------------- 

<%@ Page Language="C#"  Debug="true" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>
<html>
<script runat="server" language="c#">
       void Page_Load (object sender, EventArgs e)
       {
               SqlConnection cnc; 

               cnc = new SqlConnection ();
               string connectionString = "hostaddr=200.206.158.45;" +
                                         "PORT=5432;" +
                                         "user=ziral;" +
                                         "password=ziral;" +
                                         "dbname=teste"; 

               cnc.ConnectionString = connectionString;
               try {
                     cnc.Open ();
                     lbl1.Text = "Connected: ";
               } catch (Exception e2) {
                     lbl1.Text = "The error was: " + e2.Message;
               }
               IDbCommand selectCommand = cnc.CreateCommand();
               IDataReader reader;
               if (selectCommand == null)
                   lbl1.Text = "Null";
                   else
                   lbl1.Text = "Not Null"; 

               string selectCmd = "SELECT * FROM aluno";
               selectCommand.CommandText = selectCmd;
               reader = selectCommand.ExecuteReader ();
               lbl1.Text = "Executed ";
               while (reader.Read ()) {
               Response.Write (reader.GetString(0) + ", " + 
reader.GetString(1));
               }
               cnc.Close();
       } 

</script> 

<head>
<title>Some DB testing</title>
</head>
<body>
<form runat=server>
<asp:label id="lbl1" Text="No changed" runat="server"/>
</form>
</body>
</html> 

 ----------------------- 

The database is OK, I can use it via psql.
I think Page_Load event is not being fired
The page is located in this address http://200.206.158.45/db.aspx 

 

Thanks in advance, 

Carlos Cesario