im currently working with my teammates on a project concerning a connection between c# and a PostgreSQL database. We've had no problem on reading the database through the program , but when it came to Updating it we've had an issue. In our situation there is a table with 2 columns, the table is named acted and the columns are named actor_id and movie_id. We're using the Npgsql method to connect the database to our program and even though there is no error, every time we try to update a value on a column , nothing actually happens and the value remains the same.
This i the method that we are using
public List<string> PostgreSQLtest5() //endolse pros tin postgresql meros 1
{
String actcolumn = ??????;
String actnewvalue = ??????;
String actoldvalue = ??????;
try
{
string connstring = "Server=127.0.0.1; Port=5432; User Id=postgres; Password=72677267; Database=imdb;";
NpgsqlConnection connection = new NpgsqlConnection(connstring);
connection.Open();
NpgsqlCommand command = new NpgsqlCommand("UPDATE acted SET '"+actcolumn+"' = '"+actnewvalue+"' WHERE '"+actoldvalue+"'", connection);
NpgsqlDataReader dataReader = command.ExecuteReader();
connection.Close();
return dataItems;
}
catch (Exception msg)
{
MessageBox.Show(msg.ToString());
throw;
}
}
We have 3 textboxes in another form named acted. What do we have to write in the question marks in these 3 variables to get the input of the textboxes in here, and make it work ?