Insert Query into postgresql using Table Adapter C#

534 Views Asked by At

I am trying to insert data into a postgresql table in visual studio windows forms table adapter using this query;

    INSERT INTO PUBLIC .cashaccount
VALUES (:cashmemo, :cashcredit, :cashdebit)

I am using the ':' because I am aware the '@' operator does not work in postgresql but I am still getting a syntax error. I have googled this issue and I am yet to find a postgresql insert command with variables. Does anyone have an idea on how to make the above statement work?

1

There are 1 best solutions below

1
Rahul On

I believe the syntax error your are getting is due to the space in your table name as pointed below

INSERT INTO PUBLIC .cashaccount
                  ^----Here
VALUES (:cashmemo, :cashcredit, :cashdebit)

Also, read through Npgsql(.NET Postgresql provider) for more information with lots of examples.