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

Using RFX_Text_Bulk

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpworkspace
13 Posts 2 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.
  • L Offline
    L Offline
    Larry Mills Sr
    wrote on last edited by
    #1

    void RFX_Text_Bulk(    CFieldExchange* pFX,    LPCTSTR szName,    LPSTR* prgStrVals,    long** prgLengths,// show how to setup and implement    int nMaxLength ); I need for someone to show me how to setup and implement this field "   long** prgLengths" all examples I've seen shows long* prgLengths   in the header and prgLengths =   NULL; in the constructor. I tried that in my program and it came up with an error(compiler) that last two varables not implemented, meaning long** prgLengths and int nMaxLength . I have a CString that can at times greatly exceed the max of 255 char. That's why I need to implement the RFX_Text_Bulk function, but I can't find an example to show me how to do so. Can anyone show me how with a working example.   Please note that most times this varable will not be longer that 255 char, then there are times that it will!

    A C++ programming language novice, but striving to learn

    L 1 Reply Last reply
    0
    • L Larry Mills Sr

      void RFX_Text_Bulk(    CFieldExchange* pFX,    LPCTSTR szName,    LPSTR* prgStrVals,    long** prgLengths,// show how to setup and implement    int nMaxLength ); I need for someone to show me how to setup and implement this field "   long** prgLengths" all examples I've seen shows long* prgLengths   in the header and prgLengths =   NULL; in the constructor. I tried that in my program and it came up with an error(compiler) that last two varables not implemented, meaning long** prgLengths and int nMaxLength . I have a CString that can at times greatly exceed the max of 255 char. That's why I need to implement the RFX_Text_Bulk function, but I can't find an example to show me how to do so. Can anyone show me how with a working example.   Please note that most times this varable will not be longer that 255 char, then there are times that it will!

      A C++ programming language novice, but striving to learn

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      My best guess without reading the documentation:

      CFieldExchange fieldX;
      LPCTSTR szName[256];
      LPSTR prgStrVals;
      long* prgLengths;
      int nMaxLength = 255;

      RFX_Text_Bulk(&fieldX, szName, &prgStrVals, &prgLengths, nMaxLength);

      Just provide the address of the variable that is a pointer to a long.

      L 1 Reply Last reply
      0
      • L Lost User

        My best guess without reading the documentation:

        CFieldExchange fieldX;
        LPCTSTR szName[256];
        LPSTR prgStrVals;
        long* prgLengths;
        int nMaxLength = 255;

        RFX_Text_Bulk(&fieldX, szName, &prgStrVals, &prgLengths, nMaxLength);

        Just provide the address of the variable that is a pointer to a long.

        L Offline
        L Offline
        Larry Mills Sr
        wrote on last edited by
        #3

        Sorry, that doesn't work.   I thought the same thing. they want something for "prgLengths" but I don't know what. I've tried many examples shown through out the internet, but the errors remain.

        A C++ programming language novice, but striving to learn

        L 1 Reply Last reply
        0
        • L Larry Mills Sr

          Sorry, that doesn't work.   I thought the same thing. they want something for "prgLengths" but I don't know what. I've tried many examples shown through out the internet, but the errors remain.

          A C++ programming language novice, but striving to learn

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I took a look at the MSDN page[^] and think it should be something like this

          CFieldExchange fieldX;
          LPCTSTR pszName = "ColName";
          LPSTR prgStrVals\[nRows\];
          long prgLengths\[nRows\];
          for (int i = 0; i < nRows; ++i)
          {
              prgStrVals\[i\] = (LPSTR)new char\[256\];
          }
          int nMaxLength = 256;
          
          RFX\_Text\_Bulk(&fieldX, pszName, &prgStrVals, &prgLengths, nMaxLength);
          

          The prgStrVals and prgLengths fields are arrays that will be filled by the function, so you need to pre-allocate enough for the number of rows you are transferring. Each entry in prgStrVals is a pointer to a buffer that will hold the data for the appropriate row, so each of these buffers must be long enough to hold the longest data item. The maximum length of the items to be stored is indicated by the nMaxLength field. [edit]Added the link to the MSDN entry[/edit]

          L 1 Reply Last reply
          0
          • L Lost User

            I took a look at the MSDN page[^] and think it should be something like this

            CFieldExchange fieldX;
            LPCTSTR pszName = "ColName";
            LPSTR prgStrVals\[nRows\];
            long prgLengths\[nRows\];
            for (int i = 0; i < nRows; ++i)
            {
                prgStrVals\[i\] = (LPSTR)new char\[256\];
            }
            int nMaxLength = 256;
            
            RFX\_Text\_Bulk(&fieldX, pszName, &prgStrVals, &prgLengths, nMaxLength);
            

            The prgStrVals and prgLengths fields are arrays that will be filled by the function, so you need to pre-allocate enough for the number of rows you are transferring. Each entry in prgStrVals is a pointer to a buffer that will hold the data for the appropriate row, so each of these buffers must be long enough to hold the longest data item. The maximum length of the items to be stored is indicated by the nMaxLength field. [edit]Added the link to the MSDN entry[/edit]

            L Offline
            L Offline
            Larry Mills Sr
            wrote on last edited by
            #5

            Please excuse my ignorance: This particular record only has one column data that requires at least 1024 chars so how do I set that colum up to receive and return 1024 chars (if that is the amount inputed? the column's varable is "m_Instructions", which is the "Preparation Instructions for a recipe. please use this data in your explaination: Note there are 58 varables in this record. pszName = "Instructions";//Column header prgStrVals = "m_Instructions"// varable prgLengths = ???//don't know nMaxLength = 1024; RFX_Text_Bulk(fieldX, pszName, &prgStrVals, &prgLengths, nMaxLength);

            A C++ programming language novice, but striving to learn

            modified on Sunday, December 13, 2009 10:41 AM

            L 1 Reply Last reply
            0
            • L Larry Mills Sr

              Please excuse my ignorance: This particular record only has one column data that requires at least 1024 chars so how do I set that colum up to receive and return 1024 chars (if that is the amount inputed? the column's varable is "m_Instructions", which is the "Preparation Instructions for a recipe. please use this data in your explaination: Note there are 58 varables in this record. pszName = "Instructions";//Column header prgStrVals = "m_Instructions"// varable prgLengths = ???//don't know nMaxLength = 1024; RFX_Text_Bulk(fieldX, pszName, &prgStrVals, &prgLengths, nMaxLength);

              A C++ programming language novice, but striving to learn

              modified on Sunday, December 13, 2009 10:41 AM

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Larry Mills Sr wrote:

              Please excuse my ignorance

              No excuse needed, you are merely trying to learn. I think the following should do it:

              CFieldExchange fieldX;       // this will probably be defined elsewhere
              LPCTSTR pszName = "Recipe";  // column name \[ or should it be "m\_Instructions" ? \]
              int nRows = ?;               // set this to the number of rows in the data source
              int nMaxLength = 1024;       // max length of each row of data returned
              LPSTR prgStrVals\[nRows\];     // the rows of data will be stored in these fields
              long prgLengths\[nRows\];      // the length of the data stored in prgStrVals goes in these fields
              // initialise the strings for storing the data
              for (int i = 0; i < nRows; ++i)
              {
                  prgStrVals\[i\] = (LPSTR)new char\[nMaxLength\];
              }
              
              RFX\_Text\_Bulk(&fieldX, pszName, &prgStrVals, &prgLengths, nMaxLength);
              

              pszName is the name of the column in the data source; I'm not sure which that should be, but you will. The array prgStrVals needs to be lare enough to accept all the rows of data from the source (I guess there is some way of finding this value) and each entry is a pointer to a buffer of at least 1024 characters, as set in the for loop. On return if successful each entry in prgStrVals should contain the text from the corresponding row, and each entry in prgLengths should contain the length of that data.

              L 1 Reply Last reply
              0
              • L Lost User

                Larry Mills Sr wrote:

                Please excuse my ignorance

                No excuse needed, you are merely trying to learn. I think the following should do it:

                CFieldExchange fieldX;       // this will probably be defined elsewhere
                LPCTSTR pszName = "Recipe";  // column name \[ or should it be "m\_Instructions" ? \]
                int nRows = ?;               // set this to the number of rows in the data source
                int nMaxLength = 1024;       // max length of each row of data returned
                LPSTR prgStrVals\[nRows\];     // the rows of data will be stored in these fields
                long prgLengths\[nRows\];      // the length of the data stored in prgStrVals goes in these fields
                // initialise the strings for storing the data
                for (int i = 0; i < nRows; ++i)
                {
                    prgStrVals\[i\] = (LPSTR)new char\[nMaxLength\];
                }
                
                RFX\_Text\_Bulk(&fieldX, pszName, &prgStrVals, &prgLengths, nMaxLength);
                

                pszName is the name of the column in the data source; I'm not sure which that should be, but you will. The array prgStrVals needs to be lare enough to accept all the rows of data from the source (I guess there is some way of finding this value) and each entry is a pointer to a buffer of at least 1024 characters, as set in the for loop. On return if successful each entry in prgStrVals should contain the text from the corresponding row, and each entry in prgLengths should contain the length of that data.

                L Offline
                L Offline
                Larry Mills Sr
                wrote on last edited by
                #7

                Perhaps it would help if I enclosed my Recordset: Recordset header(part):      LONG_PTR prgLengths;      int nMaxLength;      int nRows;                     // set this to the number of rows in the data      long     m_ID;      CString     m_Category;      CString     m_RecipeName;      CString     m_RecipeType;      CString     m_FullFilePath;      CString     m_Ingred1;      CString     m_Amt1;      CString     m_Unit1;      CString     m_Ingred2;      CString     m_Amt2;      CString     m_Unit2;      CString     m_Ingred3;      CString     m_Amt3;      CString     m_Unit3;      CString     m_Ingred4;      CString     m_Amt4;      CString     m_Unit4;      CString     m_Ingred5;      CString     m_Amt5;      CString     m_Unit5;      CString     m_Ingred6;      CString     m_Amt6;      CString     m_Unit6;      CString     m_Ingred7;      CString     m_Amt7;      CString     m_Unit7;      CString     m_Ingred8;      CString     m_Amt8;      CString     m_Unit8;      CString     m_Ingred9;      CString     m_Amt9;      CString     m_Unit9;      CString   &nb

                L 1 Reply Last reply
                0
                • L Larry Mills Sr

                  Perhaps it would help if I enclosed my Recordset: Recordset header(part):      LONG_PTR prgLengths;      int nMaxLength;      int nRows;                     // set this to the number of rows in the data      long     m_ID;      CString     m_Category;      CString     m_RecipeName;      CString     m_RecipeType;      CString     m_FullFilePath;      CString     m_Ingred1;      CString     m_Amt1;      CString     m_Unit1;      CString     m_Ingred2;      CString     m_Amt2;      CString     m_Unit2;      CString     m_Ingred3;      CString     m_Amt3;      CString     m_Unit3;      CString     m_Ingred4;      CString     m_Amt4;      CString     m_Unit4;      CString     m_Ingred5;      CString     m_Amt5;      CString     m_Unit5;      CString     m_Ingred6;      CString     m_Amt6;      CString     m_Unit6;      CString     m_Ingred7;      CString     m_Amt7;      CString     m_Unit7;      CString     m_Ingred8;      CString     m_Amt8;      CString     m_Unit8;      CString     m_Ingred9;      CString     m_Amt9;      CString     m_Unit9;      CString   &nb

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Larry Mills Sr wrote:

                  RFX_Text_Bulk(pFX, _T("[Instructions]"), (LPSTR *)&m_Instructions,(long**)prgLengths,nMaxLength);//doesn't work

                  I think you are trying to make something that which it is not, by the use of casts; if you'll pardon my circumlocution. The third field of the RFX_Text_Bulk() call must be "A pointer to an array of LPSTR values", as defined in my previous post. The for loop initialises each entry to a buffer that can hold up to the maximum length of data for the column in question. However you are trying to cast the address of a CString to an array of pointers, which will not work. However, having looked again at what you are doing I am getting the feeling that the RFX_Text_Bulk() call is not what you need, you should be using the RFX_Text() call, the same as all the other fields, but with a nMaxLength value thus:

                  RFX_Text(pFX, _T("[Instructions]"), m_Instructions, 1024);

                  I guess you may have been confused by the definition on the MSDN page[^]. Where it says int nMaxLength = 255, in the function definition, which just means that if you do not specifiy a value for this field the compiler will automatically use 255. You are still at liberty to use a smaller or larger value in the range [1 to INT_MAX].

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    Larry Mills Sr wrote:

                    RFX_Text_Bulk(pFX, _T("[Instructions]"), (LPSTR *)&m_Instructions,(long**)prgLengths,nMaxLength);//doesn't work

                    I think you are trying to make something that which it is not, by the use of casts; if you'll pardon my circumlocution. The third field of the RFX_Text_Bulk() call must be "A pointer to an array of LPSTR values", as defined in my previous post. The for loop initialises each entry to a buffer that can hold up to the maximum length of data for the column in question. However you are trying to cast the address of a CString to an array of pointers, which will not work. However, having looked again at what you are doing I am getting the feeling that the RFX_Text_Bulk() call is not what you need, you should be using the RFX_Text() call, the same as all the other fields, but with a nMaxLength value thus:

                    RFX_Text(pFX, _T("[Instructions]"), m_Instructions, 1024);

                    I guess you may have been confused by the definition on the MSDN page[^]. Where it says int nMaxLength = 255, in the function definition, which just means that if you do not specifiy a value for this field the compiler will automatically use 255. You are still at liberty to use a smaller or larger value in the range [1 to INT_MAX].

                    L Offline
                    L Offline
                    Larry Mills Sr
                    wrote on last edited by
                    #9

                    I tried that, and while it gave me no errors; it also DID NOT put all the data from m_Instructions into the database (It has the data in the varable before calling Update();)

                    A C++ programming language novice, but striving to learn

                    L 2 Replies Last reply
                    0
                    • L Larry Mills Sr

                      I tried that, and while it gave me no errors; it also DID NOT put all the data from m_Instructions into the database (It has the data in the varable before calling Update();)

                      A C++ programming language novice, but striving to learn

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Larry Mills Sr wrote:

                      I tried that, and while it gave me no errors; it also DID NOT put all the data from m_Instructions into the database (It has the data in the varable before calling Update();)

                      Well I'm afraid I'm a bit lost now as I thought you were trying to read data out of the database. I cannot see anything wrong with the last set of calls unless you are doing it in the wrong direction somehow.

                      1 Reply Last reply
                      0
                      • L Larry Mills Sr

                        I tried that, and while it gave me no errors; it also DID NOT put all the data from m_Instructions into the database (It has the data in the varable before calling Update();)

                        A C++ programming language novice, but striving to learn

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        Larry Mills Sr wrote:

                        it also DID NOT put all the data from m_Instructions into the database (It has the data in the varable before calling Update();)

                        Well having slept on this I guess we are now into a new problem. May I suggest you post as a new question showing how you are trying the database update and how your program variables map to the database fields. I know there are a lot of very smart DB experts on this site so I'm sure one of them will pick it up quite quickly.

                        L 1 Reply Last reply
                        0
                        • L Lost User

                          Larry Mills Sr wrote:

                          it also DID NOT put all the data from m_Instructions into the database (It has the data in the varable before calling Update();)

                          Well having slept on this I guess we are now into a new problem. May I suggest you post as a new question showing how you are trying the database update and how your program variables map to the database fields. I know there are a lot of very smart DB experts on this site so I'm sure one of them will pick it up quite quickly.

                          L Offline
                          L Offline
                          Larry Mills Sr
                          wrote on last edited by
                          #12

                          Because of the prior code listing I'll post all the code here. How I write to the DB void CCookItDBDoc::OnRecordNew(CRecipeData cData, int nIndex)      {      m_cRecipeData.CleanUp();      m_cRecipeData = cData;      //CheckStrSize();      //m_CookItDBSet.CleanUp();      TRY           {           if (m_CookItDBSet.Open(CRecordset::dynaset, NULL, CRecordset::appendOnly))                {                m_CookItDBSet.AddNew();                if(nIndex == 0)                     {                     m_CookItDBSet.m_ID = 1;                     }                //nRecord = m_CookItDBSet.m_ID;                //m_CookItDBSet.CleanUp();                m_CookItDBSet.m_Category = m_cRecipeData.m_csCategory;                m_CookItDBSet.m_RecipeName = m_cRecipeData.m_csRecipeName;                m_CookItDBSet.m_RecipeType = m_cRecipeData.m_csRecipeType;                m_CookItDBSet.m_FullFilePath = m_cRecipeData.m_csFullFilePath;                m_CookItDBSet.m_Ingred1 = m_cRecipeData.m_csIngred1;                m_CookItDBSet.m_Amt1 = m_cRecipeData.m_csAmt1;                m_CookItDBSet.m_Unit1 = m_cRecipeData.m_csUnit1;                m_CookItDBSet.m_Ingred2 = m_cRecipeData.m_csIngred2;                m_CookItDBSet.m_Amt2 = m_cRecipeData

                          L 1 Reply Last reply
                          0
                          • L Larry Mills Sr

                            Because of the prior code listing I'll post all the code here. How I write to the DB void CCookItDBDoc::OnRecordNew(CRecipeData cData, int nIndex)      {      m_cRecipeData.CleanUp();      m_cRecipeData = cData;      //CheckStrSize();      //m_CookItDBSet.CleanUp();      TRY           {           if (m_CookItDBSet.Open(CRecordset::dynaset, NULL, CRecordset::appendOnly))                {                m_CookItDBSet.AddNew();                if(nIndex == 0)                     {                     m_CookItDBSet.m_ID = 1;                     }                //nRecord = m_CookItDBSet.m_ID;                //m_CookItDBSet.CleanUp();                m_CookItDBSet.m_Category = m_cRecipeData.m_csCategory;                m_CookItDBSet.m_RecipeName = m_cRecipeData.m_csRecipeName;                m_CookItDBSet.m_RecipeType = m_cRecipeData.m_csRecipeType;                m_CookItDBSet.m_FullFilePath = m_cRecipeData.m_csFullFilePath;                m_CookItDBSet.m_Ingred1 = m_cRecipeData.m_csIngred1;                m_CookItDBSet.m_Amt1 = m_cRecipeData.m_csAmt1;                m_CookItDBSet.m_Unit1 = m_cRecipeData.m_csUnit1;                m_CookItDBSet.m_Ingred2 = m_cRecipeData.m_csIngred2;                m_CookItDBSet.m_Amt2 = m_cRecipeData

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #13

                            I'm afraid I have nothing to suggest now as this appears to be a database issue, and my DB skills are minimal at best. As I suggested earier I think you should start a new thread in the Database forum and see if one of the experts can help.

                            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