01.
02.
03.
04.
OdbcConnection connection =
new
OdbcConnection(
"DSN=PostgreSQL"
);
05.
06.
07.
08.
09.
10.
connection.Open();
11.
System.Console.WriteLine(
"State: "
+ connection.State.ToString());
12.
13.
14.
15.
16.
17.
string
query =
"SELECT * FROM TESTTABLE"
;
18.
OdbcCommand command =
new
OdbcCommand(query, connection);
19.
20.
21.
22.
OdbcDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
23.
24.
25.
26.
27.
while
(reader.Read() ==
true
)
28.
{
29.
Console.WriteLine(
"New Row:"
);
30.
for
(
int
i = 0; i < reader.FieldCount; i++)
31.
{
32.
Console.WriteLine(reader.GetString(i));
33.
}
34.
}
35.
36.
37.
reader.Close();
38.
connection.Close();