<%@ Page language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Npgsql" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html><head><title>PostgreSQL Example 2</title>
<script language="vb" runat="Server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim conn As NpgsqlConnection
Dim comm As NpgsqlCommand
Dim sdr As NpgsqlDataReader
Try
conn = New NpgsqlConnection("Server=127.0.0.1;Port=5432;Userid=Test;password=test;Protocol=3;SSL=false;Pooling=true;MinPoolSize=1;MaxPoolSize=20;Encoding=UNICODE;Timeout=15;SslMode=Disable")
comm = New NpgsqlCommand
comm.Connection = conn
conn.Open()
comm.CommandType = CommandType.Text
comm.CommandText = "SELECT ""LName"", ""FName"" FROM ""Customers"";"
sdr = comm.ExecuteReader()
Response.Write("<table border=""1"">")
Response.Write("<tr><th>Last Name</th><th>First Name</th></tr>")
While (sdr.Read())
Response.Write("<tr>")
Response.Write("<td>")
Response.Write(sdr(0))
Response.Write("</td>")
Response.Write("<td>")
Response.Write(sdr(1))
Response.Write("</td>")
Response.Write("</tr>")
End While
Response.Write("</table>")
sdr.Close()
Catch ex As Npgsql.NpgsqlException
Response.Write("Postgre Exception: " + ex.ToString())
Catch ex As Exception
Response.Write("Exception: " + ex.ToString())
Finally
If (conn.State = System.Data.ConnectionState.Open) Then
conn.Close()
End If
conn.Dispose()
comm.Dispose()
sdr.Dispose()
End Try
End Sub
</script></head>
<body>
<form id="frmPostgreSQLExample2" method="post" runat="server">
</form></body></html>