I'm using PostgreSQL DB, and I want to make a data displayer for my friend who doesn't know SQL but sometimes he need to get some information.
I want to write a Windows Forms application which should allow him to type some client id and in result give him some data about this client.
I wrote something like this (below) and I am stuck - after clicking a button I want to pass the answer of my query to a textBox and I can't, tried many solutions. None worked. Anyone can help ?
private void btShowData_Click(object sender, EventArgs e)
{
NpgsqlConnection conn = new NpgsqlConnection("Server=someServer;Port=1234;User ID=some_user;Password=123456;Database=someDataBase;");
conn.Open();
NpgsqlCommand answer1 = new NpgsqlCommand("SELECT column1 FROM table1 WHERE id = :userId", conn);
answer1.Parameters.Add(new NpgsqlParameter("userId", NpgsqlTypes.NpgsqlDbType.Integer));
answer1.Parameters[0].Value = tbId.Text;
// HERE IS MY PROBLEM - How to pass the answer1 result to the textbox
}