Click to See Complete Forum and Search --> : Writing SQL statement


delbert Harry
April 21st, 1999, 12:11 PM
How do you write a SQL statement with text in vc. I tried [\"sometext\"], but this does not work.

PeterK
April 21st, 1999, 01:33 PM
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);

Stefan Tchekanov
April 23rd, 1999, 12:09 AM
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.