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

    Writing SQL statement

    How do you write a SQL statement with text in vc. I tried [\"sometext\"], but this does not work.


  2. #2
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    Re: Writing SQL statement

    I am a little confused as to what you are trying to do but here is a sample.
    Hope it helps.

    CString sqlWhere;
    sqlWhere.Format("WHERE eip.[Institution] = %ld AND eip.[Type] = 'Reason' ", m_instID);



  3. #3

    Re: Writing SQL statement

    CDatabase* db;
    // Get db from somewhere, e.g. db = new CDatabase; db->Open(...);

    CString cCustName = "The Customer";
    CString cSQL;
    cSQL.Format( "INSERT INTO customers (NAME) VALUES( '%s' )", cCustName );

    // Here you have the value:
    // "INSERT INTO customers (NAME) VALUES( 'The Customer' )" in cSQL

    db->Execute( cSQL );

    I hope this helps.



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