Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Connect database when start with window

Connect database when start with window

Scheduled Pinned Locked Moved C / C++ / MFC
databasedebugginghelp
22 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Rajesh R Subramanian

    capint wrote:

    This application has requested the Runtime to terminate it in an unusual way Some one plz explain for me & give me a solution [Rose]

    Please read the guidelines[^] and rephrase your question in accordance to it. With the information you've provided, I can only tell that there's "something wrong" with your code. That may not be a very helpful reply though.

    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

    C Offline
    C Offline
    capint
    wrote on last edited by
    #3

    I mean that I connected successfully & I used it properly when I directly click on the application file. It just doesn't do well when start with window. Here is a part of my code. Plz help me :confused:

    iSize = 0;
    DateTimeNote Temp;
    bool bFlag = true;
    Open("Provider=Microsoft.Jet.OLEDB.4.0; \
    Data Source=DateNote.mdb");
    CString sql;
    variant_t vNull;
    variant_t TheValue;

    vNull.vt = VT\_ERROR;
    vNull.scode = DISP\_E\_PARAMNOTFOUND;
    

    CString StrResult;
    CString StrSql;
    CString StrDateTime;
    CString StrDateTimeTemp;

    StrDateTime.Format(_T("%i/%i/%i"),DateTime.GetMonth(),DateTime.GetDay(),DateTime.GetYear());
    StrSql.Format(_T("SELECT * FROM DATETIMENOTE WHERE NGAY = '%s'"), StrDateTime);

    m_pRecordset.CreateInstance(__uuidof(Recordset));
    m_pRecordset->PutRefActiveConnection(m_pConnection);
    m_pRecordset->Open(_variant_t(StrSql), vNull, adOpenForwardOnly, adLockOptimistic, adCmdText);

    while (!m_pRecordset->GetEndOfFile())
    {
    TheValue = m_pRecordset->GetCollect("GIO");
    if(TheValue.vt != VT_NULL)
    {
    StrResult = (char *)_bstr_t(TheValue);
    StrDateTimeTemp = StrDateTime + _T(" ") + StrResult;
    Temp.DateTime.ParseDateTime(StrDateTimeTemp, LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT);
    }
    TheValue = m_pRecordset->GetCollect("NOTE");
    if(TheValue.vt != VT_NULL)
    {
    StrResult = (char *)_bstr_t(TheValue);
    Temp.Note = StrResult;
    }
    pTemp[iSize] = Temp;
    iSize ++;
    m_pRecordset->MoveNext();
    }

    R 1 Reply Last reply
    0
    • C capint

      I mean that I connected successfully & I used it properly when I directly click on the application file. It just doesn't do well when start with window. Here is a part of my code. Plz help me :confused:

      iSize = 0;
      DateTimeNote Temp;
      bool bFlag = true;
      Open("Provider=Microsoft.Jet.OLEDB.4.0; \
      Data Source=DateNote.mdb");
      CString sql;
      variant_t vNull;
      variant_t TheValue;

      vNull.vt = VT\_ERROR;
      vNull.scode = DISP\_E\_PARAMNOTFOUND;
      

      CString StrResult;
      CString StrSql;
      CString StrDateTime;
      CString StrDateTimeTemp;

      StrDateTime.Format(_T("%i/%i/%i"),DateTime.GetMonth(),DateTime.GetDay(),DateTime.GetYear());
      StrSql.Format(_T("SELECT * FROM DATETIMENOTE WHERE NGAY = '%s'"), StrDateTime);

      m_pRecordset.CreateInstance(__uuidof(Recordset));
      m_pRecordset->PutRefActiveConnection(m_pConnection);
      m_pRecordset->Open(_variant_t(StrSql), vNull, adOpenForwardOnly, adLockOptimistic, adCmdText);

      while (!m_pRecordset->GetEndOfFile())
      {
      TheValue = m_pRecordset->GetCollect("GIO");
      if(TheValue.vt != VT_NULL)
      {
      StrResult = (char *)_bstr_t(TheValue);
      StrDateTimeTemp = StrDateTime + _T(" ") + StrResult;
      Temp.DateTime.ParseDateTime(StrDateTimeTemp, LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT);
      }
      TheValue = m_pRecordset->GetCollect("NOTE");
      if(TheValue.vt != VT_NULL)
      {
      StrResult = (char *)_bstr_t(TheValue);
      Temp.Note = StrResult;
      }
      pTemp[iSize] = Temp;
      iSize ++;
      m_pRecordset->MoveNext();
      }

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #4

      Did you try debugging the application? Where is the crash happening?

      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

      C 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Did you try debugging the application? Where is the crash happening?

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

        C Offline
        C Offline
        capint
        wrote on last edited by
        #5

        How can I debug the application ? It worked properly when I debug in VC. When window starts, it just announces a message

        R 1 Reply Last reply
        0
        • C capint

          How can I debug the application ? It worked properly when I debug in VC. When window starts, it just announces a message

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #6

          capint wrote:

          How can I debug the application ?

          By setting a breakpoint and starting the debugger.

          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

          C C 2 Replies Last reply
          0
          • R Rajesh R Subramanian

            capint wrote:

            How can I debug the application ?

            By setting a breakpoint and starting the debugger.

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

            C Offline
            C Offline
            capint
            wrote on last edited by
            #7

            Can you explain more ? Where to put the breakpoint & how to start the debugger ? I mean with the application (file with the extension .exe)

            R 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              capint wrote:

              How can I debug the application ?

              By setting a breakpoint and starting the debugger.

              Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #8

              I think his application is started as a service when windows starts, so it's a bit too late to open VC and attach the debugger ;)

              Cédric Moonen Software developer
              Charting control [v1.4]

              R 1 Reply Last reply
              0
              • C Cedric Moonen

                I think his application is started as a service when windows starts, so it's a bit too late to open VC and attach the debugger ;)

                Cédric Moonen Software developer
                Charting control [v1.4]

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #9

                May be. But I couldn't make out anything from what he said. :)

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                C C 2 Replies Last reply
                0
                • R Rajesh R Subramanian

                  May be. But I couldn't make out anything from what he said. :)

                  Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                  C Offline
                  C Offline
                  Cedric Moonen
                  wrote on last edited by
                  #10

                  The hint is in the title and in his previous message ;)

                  Cédric Moonen Software developer
                  Charting control [v1.4]

                  R 1 Reply Last reply
                  0
                  • C capint

                    Can you explain more ? Where to put the breakpoint & how to start the debugger ? I mean with the application (file with the extension .exe)

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #11

                    You can also print status messages using OutputDebugString[^] and use an external debugger like DebugView[^]to view those messages. Find out where exactly your application is crashing and start investigating that portion of code.

                    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                    1 Reply Last reply
                    0
                    • R Rajesh R Subramanian

                      May be. But I couldn't make out anything from what he said. :)

                      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                      C Offline
                      C Offline
                      capint
                      wrote on last edited by
                      #12

                      So have you ever tried to connect to database through ADO and make it run with window ? Plz give me some code examples :sigh:

                      C 1 Reply Last reply
                      0
                      • C Cedric Moonen

                        The hint is in the title and in his previous message ;)

                        Cédric Moonen Software developer
                        Charting control [v1.4]

                        R Offline
                        R Offline
                        Rajesh R Subramanian
                        wrote on last edited by
                        #13

                        window != Windows for me. I actually thought he is talking about some window. Or may be that I'm not smart enough. :)

                        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                        C 1 Reply Last reply
                        0
                        • R Rajesh R Subramanian

                          window != Windows for me. I actually thought he is talking about some window. Or may be that I'm not smart enough. :)

                          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                          C Offline
                          C Offline
                          Cedric Moonen
                          wrote on last edited by
                          #14

                          Naaah, it's just that you didn't use your CPMRU properly :)

                          Cédric Moonen Software developer
                          Charting control [v1.4]

                          R 1 Reply Last reply
                          0
                          • C Cedric Moonen

                            Naaah, it's just that you didn't use your CPMRU properly :)

                            Cédric Moonen Software developer
                            Charting control [v1.4]

                            R Offline
                            R Offline
                            Rajesh R Subramanian
                            wrote on last edited by
                            #15

                            :laugh:

                            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                            1 Reply Last reply
                            0
                            • C capint

                              So have you ever tried to connect to database through ADO and make it run with window ? Plz give me some code examples :sigh:

                              C Offline
                              C Offline
                              capint
                              wrote on last edited by
                              #16

                              I'm sorry if my question is so vague. I meant Windows :sigh: I put my application path in registry (create a value in ...\Run) and I repeat my application works well when I debug in VC. It just doesn't work when Windows starts :(

                              1 Reply Last reply
                              0
                              • C capint

                                I use ADO to connect to database. I connect successfully. But when I run my application with window there's an error : Debug error : This application has requested the Runtime to terminate it in an unusual way Some one plz explain for me & give me a solution :rose:

                                D Offline
                                D Offline
                                David Crow
                                wrote on last edited by
                                #17

                                Have you seen this?

                                "Love people and use things, not love things and use people." - Unknown

                                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                C 1 Reply Last reply
                                0
                                • D David Crow

                                  Have you seen this?

                                  "Love people and use things, not love things and use people." - Unknown

                                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                  C Offline
                                  C Offline
                                  capint
                                  wrote on last edited by
                                  #18

                                  :(( I've searched for many hours but I found no result ... Some one has mentioned that problem but they didn't solve it ...

                                  D 1 Reply Last reply
                                  0
                                  • C capint

                                    :(( I've searched for many hours but I found no result ... Some one has mentioned that problem but they didn't solve it ...

                                    D Offline
                                    D Offline
                                    David Crow
                                    wrote on last edited by
                                    #19

                                    Have you tried the hotfix from Microsoft?

                                    "Love people and use things, not love things and use people." - Unknown

                                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                    C 1 Reply Last reply
                                    0
                                    • D David Crow

                                      Have you tried the hotfix from Microsoft?

                                      "Love people and use things, not love things and use people." - Unknown

                                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                      C Offline
                                      C Offline
                                      capint
                                      wrote on last edited by
                                      #20

                                      I don't know :-O I will wander some IT forum to ask if anyone has the same problem. Thanks for all of your answers :)

                                      D 1 Reply Last reply
                                      0
                                      • C capint

                                        I don't know :-O I will wander some IT forum to ask if anyone has the same problem. Thanks for all of your answers :)

                                        D Offline
                                        D Offline
                                        David Crow
                                        wrote on last edited by
                                        #21

                                        capint wrote:

                                        I don't know

                                        How can you not know if you've installed a hotfix or not? :rolleyes:

                                        "Love people and use things, not love things and use people." - Unknown

                                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                        R 1 Reply Last reply
                                        0
                                        • D David Crow

                                          capint wrote:

                                          I don't know

                                          How can you not know if you've installed a hotfix or not? :rolleyes:

                                          "Love people and use things, not love things and use people." - Unknown

                                          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                          R Offline
                                          R Offline
                                          Rajesh R Subramanian
                                          wrote on last edited by
                                          #22

                                          Don't get me started. He may not know. But, you should know it. Just get your CPMRU started. :laugh:

                                          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups