How to store an image in MySQL using MFC ODBC? - mysql

I'm getting the error message
error:Conversion is not supported
How to store an image in MySQL using MFC ODBC?
This is my code so far:
Cperson person;
person.Open();
person.MoveLast();
person.AddNew();
CFile fileImage;
CFileStatus fileStatus;
fileImage.Open(_T("hihi.jpg"), CFile::modeRead);
fileImage.GetStatus(fileStatus);
person.m_Image.m_dwDataLength = fileStatus.m_size;
HGLOBAL hGlobal = GlobalAlloc(GPTR, fileStatus.m_size);
person.m_Image.m_hData = GlobalLock(hGlobal);
fileImage.Read(person.m_Image.m_hData, fileStatus.m_size);
person.SetFieldDirty(&person.m_Image);
person.SetFieldNull(&person.m_Image, FALSE);
person.Update();
GlobalUnlock(hGlobal);
fileImage.Close();
person.Close();
//m_Image is CLongBinary
What can I do?
Error in line 'person.Update();'

Try ReadHuge instead of Raad, for more than 64k ReadHuge can be used,
fileImage.ReadHuge(person.m_Image.m_hData, fileStatus.m_size);

Related

Set data in UNB segment EDIFACT

Do you know how I can set UNB in EDIFACT?
I have a CSV input file:
VRD1;100;200;0;0;L
And the output should be:
UNA:+.? '
UNB+UNOA:2+100:14+200:14+200305:0704+00000000000000++AAA'
UNH+1+INVRPT:D:96A:UN:EAN005'
BGM+10::9+20200305070403+9
I have to map the second and third fields to UNB.
I appreciate any help in this regard. Thank you in advance.
You should be able to do this using the EdiOverride message context properties. You can find them in the Microsoft.BizTalk.Edi.BaseArtifacts assembly found in the BizTalk Server installation folder.
For instance, in an orchestration, you can do this:
EdifactMessage(EdiOverride.OverrideEDIHeader) = true;
EdifactMessage(EdiOverride.UNB2_1) = xpath(CsvMessage, ...); // 100
EdifactMessage(EdiOverride.UNB3_1) = xpath(CsvMessage, ...); // 200
Add a correlation set with the same properties to your send shape.
If you want to set them in a pipeline, use the property namespace http://schemas.microsoft.com/BizTalk/2006/edi-properties.

Equivalent of Platform::IBoxArray in C++/WinRT

I am currently porting an UWP application from C++/CX to C++/WinRT. I encountered a safe_cast<Platform::IBoxArray<byte>^>(data) where data is of type Windows::Foundation::IInspectable ^.
I know that the safe_cast is represented by the as<T> method, and I know there are functions for boxing (winrt::box_value) and unboxing (winrt::unbox_value) in WinRT/C++.
However, I need to know the equivalent of Platform::IBoxArray in order to perform the cast (QueryInterface). According to https://learn.microsoft.com/de-de/cpp/cppcx/platform-iboxarray-interface?view=vs-2017, IBoxArray is the C++/CX equivalent of Windows::Foundation::IReferenceArray, but there is no winrt::Windows::Foundation::IReferenceArray...
Update for nackground: What I am trying to achieve is retrieving the view transform attached by the HoloLens to every Media Foundation sample from its camera. My code is based on https://github.com/Microsoft/HoloLensForCV, and I got really everything working except for this last step. The problem is located around this piece of code:
static const GUID MF_EXTENSION_VIEW_TRANSFORM = {
0x4e251fa4, 0x830f, 0x4770, 0x85, 0x9a, 0x4b, 0x8d, 0x99, 0xaa, 0x80, 0x9b
};
// ...
// In the event handler, which receives const winrt::Windows::Media::Capture::Frames::MediaFrameReader& sender:
auto frame = sender.TryAcquireLatestFrame();
// ...
if (frame.Properties().HasKey(MF_EXTENSION_VIEW_TRANSFORM)) {
auto /* IInspectable */ userData = frame.Properties().Lookup(MF_EXTENSION_VIEW_TRANSFORM);
// Now I would have to do the following:
// auto userBytes = safe_cast<Platform::IBoxArray<Byte> ^>(userData)->Value;
//viewTransform = *reinterpret_cast<float4x4 *>(userBytes.Data);
}
I'm also working on porting some code from HoloLensForCV to C++/WinRT. I came up with the following solution for a very similar case (but not the exact same line of code you ask about):
auto user_data = source.Info().Properties().Lookup(c_MF_MT_USER_DATA); // type documented as 'array of bytes'
auto source_name = user_data.as<Windows::Foundation::IReferenceArray<std::uint8_t>>(); // Trial and error to get the right specialization of IReferenceArray
winrt::com_array<std::uint8_t> arr;
source_name.GetUInt8Array(arr);
winrt::hstring source_name_str{ reinterpret_cast<wchar_t*>(arr.data()) };
Specifically, you can replace the safe_cast with .as<Windows::Foundation::IReferenceArray<std::uint8_t> for a boxed array of bytes. Then, I suspect doing the same cast as me (except to float4x4* instead of wchar_t*) will work for you.
The /ZW flag is not required for my example above.
I can't believe that actually worked, but using information from https://learn.microsoft.com/de-de/windows/uwp/cpp-and-winrt-apis/interop-winrt-cx, I came up with the following solution:
Enable "Consume Windows Runtime Extension" via /ZW and use the following conversion:
auto abi = reinterpret_cast<Platform::Object ^>(winrt::get_abi(userData));
auto userBytes = safe_cast<Platform::IBoxArray<byte> ^>(abi)->Value;
viewTransform = *reinterpret_cast<float4x4 *>(userBytes->Data);
Unfortunately, the solution has the drawback of generating
warning C4447: 'main' signature found without threading model. Consider using 'int main(Platform::Array^ args)'.
But for now, I can live with it ...

How to go about creating XLS file (Matlab/HTML/JS)?

I have been using MATLAB to ask plenty of questions via questdlg and then saving all the answers as data = {'Name of variable1', 'Name of variable2', etc}. I am on a MAC so xlswrite does not work. I have used xlwrite and it works when I hit run in MATLAB. I have compiled this via the Application compiler and included the xlwrite file. When running the file, the questions are asked, but the file is not created. This is a little odd as it works and creates the file in MATLAB directly.
I switched to dlmcell and this works in MATLAB but not when run externally. As this needs to run on Windows and MAC I would have to use dlmcell? (testing on mac, then distributing on mac and windows).
What I am trying to find out, is why would it work in MATLAB but not when compiled? If this is a big problem, then I thought HTML would be a good choice. Can I write data to .txt/.xls via HTML?
prompt = {'Enter serial number'};
dlg_title = 'Serial Number';
num_lines = 1;
defaultans = {'15'};
Serial_Number = inputdlg(prompt,dlg_title,num_lines,defaultans);
SN = char(Serial_Number) %ANSWER%
prompt = {'Enter your name'};
dlg_title = 'Your name';
num_lines = 1;
defaultans = {''};
Name = inputdlg(prompt,dlg_title,num_lines,defaultans);
User = char(Name) %ANSWER%
%%PREPERATION%%
LicensePI = 'Which license is installed?'; %QUESTION%
set(0,'DefaultImageVisible','off') %Disables icon
LicensePIAns = questdlg('Which license is installed?', 'Preperation', 'Basic', 'Medium','Advanced'); %ANSWER%
LicenseGen = 'Which type of temporary license was preferred?'; %QUESTION%
LicensGenAns = questdlg('Which type of temporary license was preferred?', 'Basic', 'Medium', 'Advanced'); %ANSWER%
%%PREPERATION%%
filename = 'Test.xls';
data = {SN, User, LicensePI, LicensePIAns, LicenseGen, LicensGenAns}
dlmcell('sat.txt',data);

ActionwithAction and ActionwithDuration method giving error

I have an old code .I am trying to port it to new version of Cocos2dx It is giving me errors in the following lines.
CCSequence * pulseSequence = CCSequence::actionOneTwo(CCFadeIn::actionWithDuration(1), CCFadeOut::actionWithDuration(1));
CCRepeatForever* repeatAction = CCRepeatForever::actionWithAction(pulseSequence);
In ActiononeTwo, ActionwithDuration, and ActionwithAction method.It is telling me they are not the part of CCSequence.
CCSequence * pulseSequence = CCSequence::createWithTwoActions(CCFadeIn::create(1), CCFadeOut::create(1));
CCRepeatForever* repeatAction = CCRepeatForever::create(pulseSequence);
This should work.

Order by Domain Extension Name using CodeIgniter Active Record Class

$extension = “SUBSTRING_INDEX(domain_name, ‘.’, -1)”;
$this->db->order_by($extension, “asc”);
It says:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘asc LIMIT 50’ at line 44
But its working when I didn’t used the $this->db->order_by Active Record Class
such as this one:
$this->db->query(“SELECT * FROM domain ORDER BY SUBSTRING_INDEX(domain_name, ‘.’, -1)”);
Anyone please help me. Thanks.
I believe you'd need to extend the database active record library like this: http://codeigniter.com/wiki/Extending_Database_Drivers/
Add another argument like $escape=null to the order_by, and use it to prevent _protect_identifiers from running in your function. This would let you use an unescaped order by in the same way that select and where can be used now.
Since:
$extension = “SUBSTRING_INDEX(domain_name, ‘.’, -1)”;
$this->db->order_by($extension, “asc”);
Result to:
SUBSTRING_INDEX(domain_name, `'`.`'`, `-1)`
I edit:
system/database/drivers/mysql/mysql_driver.php
by changing:
var $_escape_char = '`';
to
var $_escape_char = '';