Click here to Skip to main content
15,891,785 members
Home / Discussions / Database
   

Database

 
AnswerRe: Time zone in SQL Server Pin
dan!sh 31-Aug-10 1:06
professional dan!sh 31-Aug-10 1:06 
GeneralRe: Time zone in SQL Server Pin
Goutam Patra31-Aug-10 2:53
professionalGoutam Patra31-Aug-10 2:53 
QuestionMax function on varchar value Pin
Nikhil Bhivgade30-Aug-10 1:17
professionalNikhil Bhivgade30-Aug-10 1:17 
AnswerRe: Max function on varchar value Pin
thatraja30-Aug-10 3:46
professionalthatraja30-Aug-10 3:46 
AnswerRe: Max function on varchar value Pin
Eddy Vluggen30-Aug-10 9:11
professionalEddy Vluggen30-Aug-10 9:11 
QuestionFilter records between Two Dates ... Pin
nassimnastaran29-Aug-10 20:35
nassimnastaran29-Aug-10 20:35 
AnswerRe: Filter records between Two Dates ... Pin
Mycroft Holmes29-Aug-10 21:48
professionalMycroft Holmes29-Aug-10 21:48 
QuestionDAORecordSet Fails to update... Pin
Kyudos29-Aug-10 13:58
Kyudos29-Aug-10 13:58 
Can anyone with any more DB experience than me, please suggest ANY reason this doesn't work... its driving me mad!

So, the in my UI the user can create an "assembly" by adding "components" to a list. I have an assembly table that links the ID of the assembly with the IDs of its constituent components, and the quantity of each component in the assembly.

Users now want to be able to create a new assembly based on an old one, so I need a copy function. Easy I though, I'll just crib the code from the single-component-add function and loop around it...

HA!

I end up with the new assembly item, but I lose the component list. The code below just creates the requisite number of blank (0, 0, 0) records in the Assembly table, but it all looks right in the debugger. Why?

if (m_pMainGrid->m_bCopyingAssembly)
{
  CDaoDatabase* pDB = GetDatabase();
  CString Filter;
  CAssemRecords* OldAssRS = new CAssemRecords(pDB);
  CAssemRecords* NewAssRS = new CAssemRecords(pDB);

  try
  {
    Filter.Format("SELECT * FROM Assemblies WHERE [Assembly Key] = %ld", lOldComponentKey);
    OldAssRS->Open(dbOpenDynaset, Filter, 0);
    NewAssRS->Open(dbOpenDynaset, "SELECT * FROM Assemblies", 0);

    if (!(OldAssRS->IsBOF() || OldAssRS->IsEOF()))
    {
      OldAssRS->MoveFirst();
      do
      {
        NewAssRS->AddNew();
        NewAssRS->Initialise();
        NewAssRS->m_Assembly_Key = lNewComponentKey;
        NewAssRS->m_Item_Key = OldAssRS->m_Item_Key;
        NewAssRS->m_Number_Length = OldAssRS->m_Number_Length;
        NewAssRS->Update();
        OldAssRS->MoveNext();
      } while (!OldAssRS->IsEOF());
    }

    ASSERT(OldAssRS->IsOpen());//debug

    if (OldAssRS->IsOpen())
    {
      OldAssRS->Close();
    }
    if (OldAssRS)
    {
      delete OldAssRS;
    }
    OldAssRS = NULL;

    ASSERT(NewAssRS->IsOpen());//debug

    if (NewAssRS->IsOpen())
    {
      NewAssRS->Close();
    }
    if (NewAssRS)
    {
      delete NewAssRS;
    }
    NewAssRS = NULL;

    m_pMainGrid->SetCopyingAssem(FALSE);
  }
  catch(CDaoException *e)
  {
    ASSERT(e->ReportError());
    e->Delete();
    OldAssRS->Close();
    NewAssRS->Close();
    return;
  }
  catch(CMemoryException *e)
  {
    e->Delete();
    OldAssRS->Close();
    NewAssRS->Close();
    return;
  }
}

AnswerRe: DAORecordSet Fails to update... Pin
Mycroft Holmes29-Aug-10 22:02
professionalMycroft Holmes29-Aug-10 22:02 
AnswerRe: DAORecordSet Fails to update... Pin
Kyudos31-Aug-10 12:34
Kyudos31-Aug-10 12:34 
Questionconvert sql2005 to sql2008 Pin
moein.serpico28-Aug-10 3:36
moein.serpico28-Aug-10 3:36 
AnswerRe: convert sql2005 to sql2008 Pin
dan!sh 28-Aug-10 4:08
professional dan!sh 28-Aug-10 4:08 
AnswerRe: convert sql2005 to sql2008 Pin
Mycroft Holmes28-Aug-10 14:28
professionalMycroft Holmes28-Aug-10 14:28 
QuestionWeird SQL Server 2005 Sybase interaction [modified] Pin
jchalfant27-Aug-10 11:10
jchalfant27-Aug-10 11:10 
AnswerRe: Wierd SQL Server 2005 Sybase interaction Pin
Mycroft Holmes27-Aug-10 12:06
professionalMycroft Holmes27-Aug-10 12:06 
GeneralRe: Wierd SQL Server 2005 Sybase interaction Pin
jchalfant30-Aug-10 2:30
jchalfant30-Aug-10 2:30 
QuestionAccess 2003 disable popup messages Pin
dcode2527-Aug-10 5:01
dcode2527-Aug-10 5:01 
AnswerRe: Access 2003 disable popup messages Pin
SilimSayo27-Aug-10 5:58
SilimSayo27-Aug-10 5:58 
GeneralRe: Access 2003 disable popup messages Pin
dcode2527-Aug-10 6:03
dcode2527-Aug-10 6:03 
AnswerRe: Access 2003 disable popup messages Pin
Luc Pattyn27-Aug-10 6:08
sitebuilderLuc Pattyn27-Aug-10 6:08 
Question@@rowcount is now working with while and if statement Pin
Jagz W27-Aug-10 0:12
professionalJagz W27-Aug-10 0:12 
AnswerRe: @@rowcount is now working with while and if statement Pin
Goutam Patra27-Aug-10 2:16
professionalGoutam Patra27-Aug-10 2:16 
GeneralRe: @@rowcount is now working with while and if statement Pin
Corporal Agarn27-Aug-10 3:49
professionalCorporal Agarn27-Aug-10 3:49 
Questionsql function for day of week Pin
Thanusree Duth26-Aug-10 23:09
Thanusree Duth26-Aug-10 23:09 
AnswerRe: sql function for day of week Pin
Mycroft Holmes26-Aug-10 23:20
professionalMycroft Holmes26-Aug-10 23:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.