-
Insert Into Error
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)
-
Re: Insert Into Error
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.
-
Re: Insert Into Error
the query per se should be like the following:
Code:
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...