strsql = "Update tbl_server(temp_no, tem_department, tem_position, tem_sname, tem_fname, tem_mname, tem_add, tem_telno, tem_bday, tem_b_place, tem_age, tem_cs, tem_fa_name, tem_ma_name, tem_spouse, tem_chil, tem_ptbc, tem_padd, tem_ptelno, tem_sss, tem_tin, tem_pag_ibig, tem_phil, tem_focc, tem_mocc, tem_sp_occ, tem_expected, tem_elem, tem_sec, tem_voc, tem_course, tem_post, tem_d_elem, tem_d_sec, tem_d_voc, tem_d_post, tem_coll, tem_d_coll) VALUES ('" & TextBox32.Text & "','" & ComboBox8.Text & "','" & ComboBox1.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & DateTimePicker7.Text & "','" & TextBox6.Text & "','" & Label27.Text & "','" & ComboBox2.Text & "','" & TextBox7.Text & "','" & TextBox9.Text & "','" & TextBox11.Text & "','" & ComboBox3.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "','" & TextBox15.Text & "','" & TextBox23.Text & "','" & TextBox24.Text & "','" & TextBox25.Text & "','" & TextBox29.Text & "','" & TextBox30.Text & "','" & TextBox31.Text & "','" & TextBox34.Text & "','" & TextBox16.Text & "','" & TextBox17.Text & "','" & TextBox18.Text & "','" & ComboBox4.Text & "','" & TextBox20.Text & "','" & DateTimePicker2.Text & "','" & DateTimePicker3.Text & "','" & DateTimePicker4.Text & "','" & DateTimePicker5.Text & "','" & TextBox19.Text & "','" & DateTimePicker6.Text & "')"
        Dim da As New MySqlDataAdapter(strsql, connection)
        da.Fill(ds)

**I am trying to save data from a temporary table to a main table but was not able to do it for an error message is displayting saying that the primary key is being doubled.... **

Can you help me what is wrong with my code??

If you want to copy records from one table to another you have to do an INSERT. Update modifies columns in existing records. The syntax of this type of insert is

INSERT INTO table2 (<list of column names>)
SELECT <list of column names> FROM table1

If the column names are the same in both tables (and are in the same order) you can use

INSERT INTO table2 SELECT * FROM table1

Because you are not allowed to have two records with the same primary key you will have to ensure that the records in table1 do not have a primary key that exists in table2.

If you just want to modify an existing record then you are likely trying to change the primary key column to a value that already exists.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.