By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 2,618 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Query Is Too Complex

P: 2
I have an interface( MFC dialog based) which interacts with a MS access DB. DB has about 20 tables. almost all of them were created manually (i mean going to ms access and creating table using design view).

Now my program needed upgrade and so as to my DB. So to do it automatically I created a small code which will check if certain field is not there then add it.

I could update my table without error. but while updating any information to the table I get this error. I really dont know how to overcome this.
any kind of help will be great help....

Expand|Select|Wrap|Line Numbers
  1. bool TableCreateQuote()
  2. {
  3.     char executeStatement[1000];
  4.  
  5.     DataBase.ExecuteSQL("CREATE TABLE Quotation1 (Quot_RevisionID TEXT(100) PRIMARY KEY,\
  6.                         QuotationID TEXT(100),\
  7.                         RevisionID  TEXT(50),\
  8.                         Lock        INTEGER)");    
  9.         return true;
  10. }
  11.  
  12. bool TableUpdateQuotation()
  13. {
  14.          while(ItTempVecRFQ_GUI != TempVecRFQ_GUI.end())
  15.     {
  16.         tempGUI1=*ItTempVecRFQ_GUI;
  17.         FieldName=tempGUI1.DBName;
  18.         FieldType=tempGUI1.DBVarType;
  19.  
  20.                exStatement="ALTER TABLE \"Quotation_Information\" ADD ";
  21.         if(FieldType.Compare("INT")==0)//type-interger(INTEGER)
  22.         {
  23.                 exStatement+=FieldName+" INTEGER";
  24.  
  25.         }
  26.         else if(FieldType.Compare("DBL")==0)//type-double
  27.         {
  28.             exStatement+=FieldName+" DOUBLE";
  29.  
  30.         }
  31.         else if(FieldType.Compare("STR")==0)//TXT-type(TEXT(100))
  32.         {
  33.             exStatement+=FieldName+" TEXT(100)";
  34.  
  35.         }
  36.         else if(FieldType.Compare("NULL")==0)
  37.         {                    
  38.             ItTempVecRFQ_GUI++;
  39.             continue;
  40.         }
  41.         else 
  42.         {
  43.             ItTempVecRFQ_GUI++;
  44.             continue;
  45.         }
  46.         strcpy(executeStatement,exStatement);
  47.  
  48.         //chk whether colum present...
  49.         if(ChkColumnInTable("Quotation1",FieldName)==FALSE)
  50.         {
  51.                       DataBase.ExecuteSQL(executeStatement);
  52.                 }
  53.         exStatement="";
  54.         ItTempVecRFQ_GUI++;
  55.          }
  56.         return true;
  57. }
  58.  
  59. //this function is called when user clicks update button in a dialog. This is 
  60. void OnButtonUpdate() 
  61. {
  62. UpdateData(TRUE);
  63.     if( !m_RS_RFQ.Open("SELECT * FROM \"Quotation1\"") )
  64.     {
  65.         TRACE("Failed to run query: \"%s\"\n","SELECT * FROM \"Quotation1\"");
  66.         //return false;
  67.     } 
  68.     else
  69.     {
  70. //go to current record
  71. //--
  72. //
  73. //starting updating fields in record
  74. m_RS_RFQ.Edit();
  75. while(--go over all field in gui)
  76. m_RS1.Field(m_DBName)=strDate;
  77. m_RS1.Field(m_DBName)=tempInt;
  78. m_RS1.Field(m_DBName)=tempDbl;
  79. m_RS1.Field(m_DBName)=tempStr;
  80. //----end of while
  81. m_RS_RFQ.Update();//I get error at this point...
  82. //--
  83.  
  84.  
  85. }
  86.  
  87. UpdateData(FALSE);
  88.  
  89. }
May 1 '10 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,186
I suggest you start by determining and posting the actual SQL that causes this error to appear. Just dumping some general code and expecting us to work out what is going on is not a very helpful way to approach this.
May 2 '10 #2

NeoPa
Expert Mod 15k+
P: 31,186
I've had a brief look at your code. It's a c type language!! Why are you asking for c type help in an Access forum? I can move it for you if you like, but I admit to being a bit confused by all this.
May 2 '10 #3

P: 2
@NeoPa
thanks for reply.
I really dont know to which forum it will belong. I am updating my access DB using c++ code. I will leave it to your desecration in moving it to right forum.
I will try to post actual sql command which is causing this issue.
May 2 '10 #4

NeoPa
Expert Mod 15k+
P: 31,186
As the actual error occurring is a Jet SQL error, I'll leave it here for now. If you can post the actual SQL then I may be able to help. If later, the problem actually turns out to be in the code itself, then I will probably move it across for you.
May 3 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.