Query Is Too Complex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • narendra911
    New Member
    • May 2010
    • 2

    Query Is Too Complex

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

    Code:
    bool TableCreateQuote()
    {
    	char executeStatement[1000];
    	
    	DataBase.ExecuteSQL("CREATE TABLE Quotation1 (Quot_RevisionID TEXT(100) PRIMARY KEY,\
    						QuotationID TEXT(100),\
    						RevisionID  TEXT(50),\
    						Lock        INTEGER)");	
            return true;
    }
    
    bool TableUpdateQuotation()
    {
             while(ItTempVecRFQ_GUI != TempVecRFQ_GUI.end())
    	{
    		tempGUI1=*ItTempVecRFQ_GUI;
    		FieldName=tempGUI1.DBName;
    		FieldType=tempGUI1.DBVarType;
    
                   exStatement="ALTER TABLE \"Quotation_Information\" ADD ";
    		if(FieldType.Compare("INT")==0)//type-interger(INTEGER)
    		{
    				exStatement+=FieldName+" INTEGER";
    		
    		}
    		else if(FieldType.Compare("DBL")==0)//type-double
    		{
    			exStatement+=FieldName+" DOUBLE";
    		
    		}
    		else if(FieldType.Compare("STR")==0)//TXT-type(TEXT(100))
    		{
    			exStatement+=FieldName+" TEXT(100)";
    		
    		}
    		else if(FieldType.Compare("NULL")==0)
    		{					
    			ItTempVecRFQ_GUI++;
    			continue;
    		}
    		else 
    		{
    			ItTempVecRFQ_GUI++;
    			continue;
    		}
    		strcpy(executeStatement,exStatement);
    
    		//chk whether colum present...
    		if(ChkColumnInTable("Quotation1",FieldName)==FALSE)
    		{
                          DataBase.ExecuteSQL(executeStatement);
                    }
    		exStatement="";
    		ItTempVecRFQ_GUI++;
             }
            return true;
    }
    
    //this function is called when user clicks update button in a dialog. This is 
    void OnButtonUpdate() 
    {
    UpdateData(TRUE);
    	if( !m_RS_RFQ.Open("SELECT * FROM \"Quotation1\"") )
    	{
    		TRACE("Failed to run query: \"%s\"\n","SELECT * FROM \"Quotation1\"");
    		//return false;
    	} 
    	else
    	{
    //go to current record
    //--
    //
    //starting updating fields in record
    m_RS_RFQ.Edit();
    while(--go over all field in gui)
    m_RS1.Field(m_DBName)=strDate;
    m_RS1.Field(m_DBName)=tempInt;
    m_RS1.Field(m_DBName)=tempDbl;
    m_RS1.Field(m_DBName)=tempStr;
    //----end of while
    m_RS_RFQ.Update();//I get error at this point...
    //--
    
    
    }
    
    UpdateData(FALSE);
    
    }
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    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.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32645

      #3
      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.

      Comment

      • narendra911
        New Member
        • May 2010
        • 2

        #4
        Originally posted by NeoPa
        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.
        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.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32645

          #5
          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.

          Comment

          Working...