CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Posts
    192

    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)

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    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...
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured