|
Member 10125032 wrote: We have deployed a kit ...My first task is to write a c or c++ program which can parse those received frames and format ... in xml format to our own event handler
Steps
- Get the spec for the 'kit' to determine what it stores.
- Read the data.
- Parse it according to what you learned from the spec. It is unlikely that any complex solutions would be required for this (hopefully, but the spec is the source.)
- The parser will create an internal format (list of structs probably) of your own devising. Probably very close to what you want to put into the xml.
- Determine what the xml looks like. Either find out what it already expects. Or design it. If the latter then someone needs to tell you what data they expect. Otherwise you have no idea what you need to get.
- Write the internal format out to xml form based on the previous step.
|
|
|
|
|
Hi all
I am writing a program to submit some files in a SQL server 2012 the problem is:
when the file size is around 255 KBytes it's all ok, but when the file is greater there is an error on "RecordSet.Update() phase. The error is : "The Pointer Value type Text, NText or image conflicts with the specified column name. ..."
The Column is declared in table as varbinary(max) the code is:
CFile file(szPathFileToOpen, CFile::modeRead);
ULONGLONG filelen = file.GetLength();
rsAttachments.AddNew();
rsAttachments.m_AttachmentsID=szUniqueID;
rsAttachments.m_FileName=m_ListAttached.GetItemText(0,0);
GlobalFree( rsAttachments.m_FileData.m_hData );
if((rsAttachments.m_FileData.m_hData=GlobalAlloc(GMEM_MOVEABLE,filelen))==NULL)
{
AfxMessageBox(_T("memory error"));
}
LPVOID pVoid = NULL;
if((pVoid=GlobalLock(rsAttachments.m_FileData.m_hData))== NULL)
{
AfxMessageBox( _T( "memory error" ));
}
file.Read(pVoid, filelen);
rsAttachments.SetFieldDirty( &rsAttachments.m_FileData, TRUE );
rsAttachments.SetFieldNull( &rsAttachments.m_FileData, FALSE );
rsAttachments.m_FileData.m_dwDataLength=GlobalSize(rsAttachments.m_FileData.m_hData );
rsAttachments.Update();
GlobalFree( rsAttachments.m_FileData.m_hData );
Thanks in advance to the angel will help me.
Giovanni
|
|
|
|
|
Where is the code that raises the error and what are the values of the parameters being referenced?
|
|
|
|
|
i am a novice with a DB programming i have put now a CDBException that return me this:
m_strStateNativeOrigin = "State:37000,Native:7125,Origin:[Microsoft][ODBC SQL Server Driver][SQL Server]
State:S1000,Native ,Origin:[Microsoft][ODBC SQL Server Driver]
It's good this?
|
|
|
|
|
Sorry, that means nothing. You need to show the exact code that causes the error, and include the values of all the parameters being used.
|
|
|
|
|
Ok already posted the code the problem occur in the moment i call Update, and when the file is greater than 255kb
|
|
|
|
|
So have you stepped into Update() , using the debugger, to see where the exception is being thrown from?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Have you verified that GlobalAlloc actually worked? Does file.Read() actually read the full file? Check the return value of the Read function to see how many bytes have been read.
255K doesn't seem that large. However, the Global** functions and the CFile class are ancient, and I wouldn't be surprised if they had some built-in restrictions...
On a sidenote, since you immediately lock the memory after allocation, why do you use GMEM_MOVEABLE ? And since you immediately free the memory after use, why do you even use the GLOBAL** functions at all, why don't you simply use new and delete instead? That would be faster, requires less code, and takes less effort to read and understand the code!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Stefan_Lang wrote: why
Stefan_Lang wrote: why do you
Stefan_Lang wrote: why don't you Copy & Paste ?
|
|
|
|
|
Hi,
Drakelor wrote: when the file size is around 255 KBytes it's all ok, but when the file is greater there is an error on "RecordSet.Update() phase. The error is : "The Pointer Value type Text, NText or image conflicts with the specified column name. ..."
You are probably storing the file into a BLOB column. All SQL columns usually have a maximum size. The error message is probably correct... if you attempt to stuff 256 KBytes into a 255 KByte data field you will obviously get an error.
I suspect that you need to regenerate your database tables. This time choose a larger column size.
Best Wishes,
-David Delaune
|
|
|
|
|
I finally resolved the issue. I explain to you.
1) Download last SQL server driver.
2) Rebind/Recreate the CRecordset, so it bind with varbinary(max) -> CBYTEARRAY
3) In Recordset Class in the line : RFX_Binary(pFX, _T("[FileData]"), m_FileData,15360000);
increase the last parameter to desidered max dimension (15MB in my case).
4) Write this simple code:
CFile cfFileToSave(szPathFileToOpen,CFile::modeRead);
rsAttachments.m_FileData.SetSize((INT_PTR)cfFileToSave.GetLength());
cfFileToSave.Read(rsAttachments.m_FileData.GetData(),(UINT)cfFileToSave.GetLength());
cfFileToSave.Close();
rsAttachments.SetFieldDirty(&rsAttachments.m_FileData,TRUE);
rsAttachments.SetFieldNull(&rsAttachments.m_FileData,FALSE);
rsAttachments.Update();
All done thanks all
|
|
|
|
|
i've problem within doing my final project, i've a project where the project can be transfer a image continues and real time. the transfer data using UDp SOcket. any referention for me to build it, i don.t know what must i do
|
|
|
|
|
|
Irwan Saifranto wrote: i don.t know what must i do A few possibilities come to mind.
- Choose a different subject, one that you do understand.
- Research the use of UDP sockets, and how to write your own data management protocol.
- Switch to TCP and research some of the many samples available on the internet.
|
|
|
|
|
Hi!
i am New Programmer of C++. please tell me how to Use Vector In Template With Return Type.Give Me Any Example With Detail Which Can Help Me In Understanding Of This Problem.
|
|
|
|
|
Member 11004573 wrote: how to Use Vector In Template With Return Type. You need to be clearer about what you mean by this. There are many samples of vectors, templates and return types to be found on MSDN[^], CodeProject articles and through Google. However, if you have a specific coding issue then please show your code and expalin what errors you have.
|
|
|
|
|
e.g.
template <typename T> T find_max(const vector <T> & v)
{
}
However, as pointed out by Richard, there are many, many possibilities, without further details cannot help more.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
I have to ask: why is it that Richard is leanings sideways in your response? Are you implying he's drunk?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Yes, Stephan
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
I have a prn file which prints bar-code. How can change the barcode value through File IO streams in VC++ 6.0
Kindly help me.
|
|
|
|
|
Can you tell what effort you put do this till now?
|
|
|
|
|
|
In order to replace content you have to recognize it. That is you have to write a (possibly simple) parser for the PRN file you are dealing with.
If the specifications of such PRN format are available then check them out, otherwise you have to (if possible) reverse engineer it.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
1. google for barcode reader source code
2. google for barcode printing source code
3. feed the former with your .prn file and get the code it represents
4. feed that to the latter to generate a new .prn file.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hello Everyone!
Please Tell Me How To CONTROL KEYBOARD ARROW key and Move Any Object Through Keys in C++,Please Tell Me If Any One Have Knowledge Abut this.
|
|
|
|