I'm currently creating a small C# program that inserts data from files into a postgres table.
The code that does the insertion looks like this:
NpgsqlCommand cmd = new NpgsqlCommand(@"INSERT INTO :table(text) VALUES (:word);", con);
cmd.Parameters.AddWithValue("table", table);
cmd.Parameters.AddWithValue("word", line);
cmd.ExecuteNonQuery();
But every time it tries to execute the "ExecuteNonquery" line I get the following error:
An unhandled exception of type 'Npgsql.NpgsqlException' occurred in Npgsql.dll
Additional information: ERROR: 42601: syntax error at or near "("
I can connect to the database I have checked. The variables table and line also have the correct values at runtime. I just can't figure out what the problem is..
Any suggestions ?