Thread: Fwd: cant insert into a post gre sql table...Can u please help in fixing this

here i am sending my actual code







  string employee = "insert into  VSP_Employee values ('" + txtEmpid.Text + "','" + txtEmpname.Text + "','" + txtEmailid.Text + "','" + txtphnum.Text + "','" + txtDOB.Text + "','"  +txtDOJ.Text + "','" + txtNOD.Text + "','" + txtSalary.Text + "','" + txtLeavestaken.Text + "','" + txtLeavesBalance.Text + "','" + txtPlannedleaves.Text+"')";
                    NpgsqlDataAdapter da = new NpgsqlDataAdapter(employee, conn);
                    cmd = new NpgsqlCommand(employee, conn);
                    da = new  NpgsqlDataAdapter(cmd);
                    ds = new DataSet();
                    da.Fill(ds, "VSP_Employee");



                              Please help me in fixing this . Thanking you

Attachment
On 4/14/2014 12:51 AM, kona ajay wrote:
>           Please help me in fixing this . Thanking you

the error seems pretty explicit.    "relation vsp_employee does not exist"

I fail to see how this is a postgres bug.


btw, thats a terrible way of programming SQL queries.  a all someone
would have to do would be to enter

     '); drop table vsp_employee;

as an employee name and you'd be in a world of hurt.  you should instead
pass in the data values as arguments to a parametrized query.   as I
don't do .NET stuff, you'll need to look up how to do that yourself.

--
john r pierce                                      37N 122W
somewhere on the middle of the left coast

Re: Fwd: cant insert into a post gre sql table...Can u please help in fixing this

From
David G Johnston
Date:
kona ajay wrote
> "insert into  VSP_Employee values [...]

If you managed to create the table in a case-sensitive manner you will need
to refer to it in the same way - namely with double-quotes surrounding the
identifier.  Otherwise all identifiers are case-folded to lower case.

"VSP_Employee" -> same
VSP_Employee -> vsp_employee

My other guess is you think you are hitting a database with the table but in
reality you are connecting to a different database where the table does not
exist.

David J.



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/cant-insert-into-a-post-gre-sql-table-Can-u-please-help-in-fixing-this-tp5799954p5799972.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.