Click to See Complete Forum and Search --> : Insert Into Error


dr223
January 13th, 2010, 07:42 AM
Hallo,

Please could someone look at the error in my insert into syntax. Thanks

query = "INSERT INTO gprdsql.TblPracDetailsHistorynw (Prac_No, Prac_Eid, Prac_Status, Version_Type, num_pats, system_type, practice_name, Address1, Address2, Address3, Town, County, Post_code, Country, telephone, email, fax, pay_status, pay_method, bank_name, bankaddress1, bankaddress2, bankaddress3, banktown, bankcounty, bankpostcode, bankcountry, pay_acc_num, pay_sort_code, coll_status, payee_name, sub_media, system_time) "
((Select(Prac_No, Prac_Eid, Prac_Status, Version_Type, num_pats, system_type, practice_name, Address1, Address2, Address3, Town, County, Post_code, Country, telephone, email, fax, pay_status, pay_method, bank_name, bankaddress1, bankaddress2, bankaddress3, banktown, bankcounty, bankpostcode, bankcountry, pay_acc_num, pay_sort_code, coll_status, payee_name, sub_media, system_time) from
gprdsql.TblPracDetails WHERE Prac_No='" & _
Me.TxtPracNo.Text & "' "), conn)

dglienna
January 13th, 2010, 07:22 PM
We can't see your DB, so how could we help? You didn't even state the error.

Also, break that down, into sections, and try each step at a time.

Cimperiali
January 14th, 2010, 07:28 AM
the query per se should be like the following:

query = "INSERT INTO gprdsql.TblPracDetailsHistorynw (Prac_No, Prac_Eid, Prac_Status, Version_Type, num_pats, system_type, practice_name, Address1, Address2, Address3, Town, County, Post_code, Country, telephone, email, fax, pay_status, pay_method, bank_name, bankaddress1, bankaddress2, bankaddress3, banktown, bankcounty, bankpostcode, bankcountry, pay_acc_num, pay_sort_code, coll_status, payee_name, sub_media, system_time) "

query=query & " Select Prac_No, Prac_Eid, Prac_Status, Version_Type, num_pats, system_type, practice_name, Address1, Address2, Address3, Town, County, Post_code, Country, telephone, email, fax, pay_status, pay_method, bank_name, bankaddress1, bankaddress2, bankaddress3, banktown, bankcounty, bankpostcode, bankcountry, pay_acc_num, pay_sort_code, coll_status, payee_name, sub_media, system_time from gprdsql.TblPracDetails WHERE Prac_No='" Me.TxtPracNo.Text & "' "


Moreover:
You should not add the connetcion string directly to the query string
take a look at the StringBuilder: it will let you add pieces of string a sentence at a time, instead of put everithing in a single long string, where you would not be able to read what you have done at the end...