0

and here is my code

public partial class Form2 : Form
   {
        NpgsqlConnection conn;
        NpgsqlCommand cmd;
        string connstring = ConfigurationManager.ConnectionStrings["EmployeeData"].ConnectionString;
        private DataSet ds = new DataSet();
        private DataTable dt = new DataTable();

        public Form2()
        {
            InitializeComponent();
            lblErrorMessage.Visible = false;
        }


        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 + "')";
        NpgsqlDataAdapter da = new NpgsqlDataAdapter(employee, conn);
        cmd = new NpgsqlCommand(employee, conn);
        da = new NpgsqlDataAdapter(cmd);
        ds = new DataSet();
        da.Fill(ds);
arco444
  • 22,002
  • 12
  • 63
  • 67
user3531533
  • 65
  • 1
  • 2
  • 9
  • I don't know anything about the DBMS in question but it looks like you're not creating the conn object and you're initializing da twice before using it. Check that stuff first and then add more error detail to your question if it's not working. – Ian Gilroy Apr 14 '14 at 10:56
  • And what's the result? Error message? Do you mean `vsp_employee` or `"VSP_Employee"`? – Erwin Brandstetter Apr 15 '14 at 21:29
  • i have even tried "VSP_Employee" but of no use @ErwinBrandstetter – user3531533 Apr 17 '14 at 09:06
  • Thank You very much - @IanGilroy. when i tried to execute the above program i have got the following error ."Npgsql.NpgsqlException: relation "vsp_employee" doesnot exist severity:error code:42P01 Can u please help me in solving this.......... THANKING YOU – user3531533 Apr 17 '14 at 09:20
  • The error message is pretty clear: The relation does not exist. There are many similar question with loads of answers here. [Example.](http://stackoverflow.com/questions/16763736/relation-does-not-exist/16763963#16763963) – Erwin Brandstetter Apr 17 '14 at 13:22
  • Thanks for the reply.... I have already cross checked both the names given are same.... no change same error@ErwinBrandstetter – user3531533 Apr 17 '14 at 13:27
  • Have you considered that you might be connecting to the wrong database? – Erwin Brandstetter Apr 18 '14 at 04:30
  • i have checked again.. i have connected to the correct database only..... – user3531533 Apr 18 '14 at 08:40
  • Any solution for my problem................@ErwinBrandstetter – user3531533 Apr 19 '14 at 04:37

0 Answers0