I am using Npgsql to access postgresql database and I am running a query: The query will return value 4, but my a gets -1.what is the problem here and how can I solve it? Answer It looks like you are using Dapper. If so, you want QueryFirst not Execute, as Execute just returns the number of rows
Tag: npgsql
Passing integer value from textbox in SQL select statement
I have an integer in a textbox(Integer retrieved from another form using TOstring) I want to use in an sql select statement. For example, select * from table where column = textbox. The problem is, npgsql gives an error saying I’m trying to pass string into integer column. I try to cast(::int) but still got errors. Any ideas! Answer I
PostgreSQL, Npgsql returning 42601: syntax error at or near “$1”
While passing PostgreSQL command following error 42601: syntax error at or near “$1” Answer After some testing I found that only table values can be passed as parameter not table name and column name. So I changed code like this