SteveoAtilla Posted August 9, 2007 Posted August 9, 2007 Hey, I am in need of help. I have an applet that processes an XML file to do transfer it to a SQL database. It needs to analyze the records to see if they are already in the DB, and do an INSERT or UPDATE. Here is the code that is trying to process the results of a SELECT query to pull a Primary Key field from the DB: // fetch CString machineMasterPK; rc = g_sqlMgr.Fetch(); if (SQL_SUCCEEDED(rc)) { LPCTSTR fieldname = SQL_MACHINE_MASTER_PK; if (*fieldname == _T('~')) ++fieldname; // loop to get the last one (just in case of the same MachineMaster data // was entered more than once). do { machineMasterPK = g_sqlMgr.GetCol(SQL_MACHINE_MASTER_PK, _T("")); cout << "Loop Field Value: " << machineMasterPK << endl; } while ( SQL_SUCCEEDED( rc=g_sqlMgr.Fetch() )); cout << "Fieldname value: " << fieldname << endl; cout << "MachineMasterPK: " << machineMasterPK << endl;What I get back is "@", but if I run the SELECT query that is being submitted and (apparently) executed successfully, I get a fully-populated record back. Here is a part of the appropirate .h file: // MachineMaster #define SQL_MACHINE_MASTER_PK _T("~MachineMasterPK") #define SQL_PRODUCTION_ORDER_NUMBER _T("~ProductionOrderNumber") #define SQL_SALES_ORDER_NUMBER _T("SalesOrderNumber") #define SQL_SALES_ORDER_ITEM _T("SalesOrderItem") #define SQL_SALES_ORDER_MATERIAL _T("SalesOrderMaterial") #define SQL_MATERIAL_DESCRIPTION _T("MaterialDescription") #define SQL_CUSTOMER_NUMBER _T("CustomerNumber") #define SQL_CUSTOMER_NAME _T("CustomerName")C++ is not my primary language, so I'm at a bit of a loss. I'm maintaining an app that I inherited. HELP!!! Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
SteveoAtilla Posted August 10, 2007 Author Posted August 10, 2007 Well, I figured out what was going on. I replaced machineMasterPK = g_sqlMgr.GetCol(SQL_MACHINE_MASTER_PK, _T(""));with machineMasterPK = g_sqlMgr.GetCol("MachineMasterPK", _T(""));and it worked great. And if I were to put in machineMasterPK = g_sqlMgr.GetCol(fieldname, _T(""));I bet it would still work. Thanks for the views. Kahuna Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.