Using RFX_Text_Bulk
-
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
-
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
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.
-
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.
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
-
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
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
andprgLengths
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 inprgStrVals
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 thenMaxLength
field. [edit]Added the link to the MSDN entry[/edit] -
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
andprgLengths
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 inprgStrVals
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 thenMaxLength
field. [edit]Added the link to the MSDN entry[/edit]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
-
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
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 arrayprgStrVals
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 thefor
loop. On return if successful each entry inprgStrVals
should contain the text from the corresponding row, and each entry inprgLengths
should contain the length of that data. -
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 arrayprgStrVals
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 thefor
loop. On return if successful each entry inprgStrVals
should contain the text from the corresponding row, and each entry inprgLengths
should contain the length of that data.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
-
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
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. Thefor
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 aCString
to an array of pointers, which will not work. However, having looked again at what you are doing I am getting the feeling that theRFX_Text_Bulk()
call is not what you need, you should be using theRFX_Text()
call, the same as all the other fields, but with anMaxLength
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]. -
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. Thefor
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 aCString
to an array of pointers, which will not work. However, having looked again at what you are doing I am getting the feeling that theRFX_Text_Bulk()
call is not what you need, you should be using theRFX_Text()
call, the same as all the other fields, but with anMaxLength
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].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
-
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
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.
-
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
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.
-
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.
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
-
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