|
...and what does this have to do with Managed C++/CLI?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Nothing whatsoever, but it is interesting to read OP's first and second comments.
|
|
|
|
|
Yes, I saw the OP's comments
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Hello,
I have a byte array that i want to set on a sqlserver database with ADO.NET.
I have an error message : Cannot convert 'signed char *' to 'System::Object ^'
What is wrong ?
Thanks in advance.
SqlConnection ^connection = gcnew SqlConnection(connectString);
connection->Open();
String ^ myRequete = "UPDATE COM_PKCS12 SET PKCS12 = @myPKCS12 WHERE ID = '" + System::Convert::ToString(id) + "'";
SqlCommand ^command = gcnew SqlCommand( myRequete, connection);
SByte * testByteArray = pkcs12Data->array;
command->Parameters->Add(gcnew SqlParameter("@myPKCS12", SqlDbType::VarBinary));
command->Parameters["@myPKCS12"]->Value = testByteArray;
int affectedrows = command->ExecuteNonQuery();
connection->Close();
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello everybody!
at first I apologize for my weak English!
I use a shared library generated by MATLAB 2012b in VC++ 2012.
In my shared libray I have a function that takes two arguments and calculates normxcorr2 between them and return maximum calculated value:
function max = Normed_CC(template, image)
....
Now I want to send two variables of type cv::Mat from my vc++ program to it.
My problem is when I convert cv::Mat to mxArray and then send these new objects to "Normed_CC", normxcorr2 in Matlab side arise an exception with this theme:
"template at least must have two item".
sorry I don't remember exactly now because I'm not in work now and don't have access to my code...!
please help me to resolve my issue.
thanks in advance.
|
|
|
|
|
i'm a beginner and want to learn but i have problem !!
"error c2679 binary '<< ' no operator found which takes a right-hand operand of type "
when i used "cin"
my code is a simple as i said i'm beginner
it's :
#include <string>
#include <iostream>
using namespace std ;
int main ()
{
int age,weight ;
float bmi , height ;
string name , z ;
//for name
cout<<"Enter your name "<<endl ;
="" cin="">>name>>endl ;
//for age
cout<<"Enter your age "<<endl ;
="" cin="">>age>>endl ;
//for weight
cout<<"Enter Your Weight "<<endl ;
="" cin="">>weight>>endl ;
// for height
cout<<"Enter your Height In Meters"<<endl ;
="" cin="">>height>>endl ;
bmi=weight/(height*height) ;
if (bmi<18.5)
z= "You Are Underweight" ;
else if ((bmi>18.5) && (bmi<24.9))
z= "You Are Normalweight" ;
else if ((bmi>24.9) && (bmi<29.9))
z= "You Are Overweight" ;
else z= "obesity " ;
cout<<"Your BMI "<<"is "<
|
|
|
|
|
Part of your error message is missing, and you forgot to show which line produces the error.
|
|
|
|
|
Hi guys,
So VS 2015 has arrived and I'd like to retarget my /clr projects to build against .NET 4.6. The project Properties page shows ".NET Target Framework Version" => "v4.5.2". But this field is non-editable (Configuration Properties > General, Project Defaults, .NET Target Framework)
I updated the SDK targeting quite easily to target the Windows 10 SDK by selecting "10.0.10240.0" in the Target Platform Version combo. Why no similar combobox for .NET targeting? grr.
I feel like I'm missing something simple but MS has never really made it simple for us C++/CLI devs.
I think must resort to hand-editing the .vcxproj files directly? Surely not.
The Add Reference dialog isn't much help either but it does confirm that I'm targeting 4.5.2.
Have you upgraded your projects yet? Is there an easy way to switch them to targeting 4.6?
John
PS. The 'help' is worthless in the properties dialog. It takes me to a "Cannot find requested topic..." page. Help Viewer content and linking has really gotten worse in 2015 in my experience so far.
|
|
|
|
|
Answering my own question for future visitors.
You must hand-edit the vcxproj but it's a pretty simple change.
Old:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
New:
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
John
|
|
|
|
|
Hi Guys!,
I'm developing program which receives name from user and create a new directory, then I've to a file with different name to that directory..
Idea is something like this:
- Name of directory to be created :
- Name of file : this file need to be saved to the created directory
I came across the use of 'mkdir', but i dont know how to use it properly
Can someone help me on this?
Thank you
|
|
|
|
|
|
That helps!. Thank you so much
|
|
|
|
|
No problem. But please try and use the correct forum in future.
|
|
|
|
|
|
What does "mkdir" have to do with C++ managed or otherwise?
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
Hi Guys,
I have to make a single bool array combining four integer arrays as follows. I'm not supposed to do as
connected = new bool [bl1 + bl2 + tr + ct];
because bl1, bl2,tr,ct are pointer to arrays. Can some one give a solution for this??
Here is my code:
class Protocol{
int baseline1[10],baseline2[10];
int catcht[20];
int training[120];
bool *connected;
public:
Protocol(int[10],int[10],int[120],int[20]);
};
<h1>include "protocol.h"</h1>
<h1>include "math.h"</h1>
Protocol::Protocol(int bl1[10], int bl2[10], int tr[120], int ct[20]){
int *baseline1 = bl1;
int *baseline2 = bl2;
int *training = tr;
int *catcht = ct;
connected = new bool [bl1 + bl2 + tr + ct];
}
Thank you!
|
|
|
|
|
You haven't explained what it means to "make a single bool array combining four integer arrays." Therefore, no one can help you yet.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Member 9350237 wrote:
connected = new bool [bl1 + bl2 + tr + ct];
because bl1, bl2,tr,ct are pointer to arrays.
That makes no sense, the value in brackets has to be the requested length of the array. So the new array needs to be long enough to contain the combined number of elements of the other arrays.
You also need to explain how you will convert from int to bool when you copy the elements of the arrays.
|
|
|
|
|
Thanks for responding!.
Sorry about my poor explanation..
I think I conveyed it a wrong way. I'm still in a confusion!
Let me try to explain the scenario..
Ultimately I need to make a bool array of length 10+120+20=150.This will be combinations of zeros and ones..
Out of which first 10 and last 20 positions are filled with '0'.
120 positions are divided into 10 sets of 12 members..
out of 12 positions 10 are ones and two zeros have to be randomly placed into this 12 locations..
for exp: Following are 1st and last set of 12 positions..
{1,1,1,1,0,1,1,1,1,0,1,1,.....1,1,0,1,1,1,0,1,1,1,1,1}
I'm bit stuck implementing this bool array...
As I mentined before
int baseline1[10], int baseline2[20] are 1st 10 and last 20 positions of the bool array which is basically '0', {0}..
int training[120] is to be assigend with zeros and ones in such a way that..
int catcht[20] array of zeros to be combined with array [120] as I mentioned before..
Sorry if my explanation is vague!
|
|
|
|
|
OK, so you know the length of the array, so you just allocate it as normal:
int arraySize = 10+120+20;
bool* boolArray = new bool[arraySize];
memset(boolArray, 0, sizeof(bool) * arraySize);
gives you an array with all elements set to zero. You now just need to add the code to set the various other items as required.
bool* pBool = boolArray + 10; for (int i = 0; i < 10; ++i) {
pBool += 12; }
|
|
|
|
|
Thanks a lot!!,
I'm wondering how to set random zeros and ones to pBool pointer!
you mean
pBool = rand()%2;
Still bit confused!
As I mentioned , for each set I have 12 numbers, out of which 10 numbers 'must' be 1 and 2 0s have to be put randomly into this block of ones, so total of 12: One set should be like this
{1,1,1,1,0,1,1,0,1,1,1,1,...} and in the 2nd set there must be 10 ones and 2 zeros , but position of zero will be different.
will be great if you can help me out on this!
|
|
|
|
|
I would do something like:
bool* pBool = boolArray + 10; srand( (unsigned)time( NULL ) ); for (int i = 0; i < 10; ++i) {
memset(pBool, 1, sizeof(bool) * 12); int rIndex = rand() % 12; pBool[rIndex] = 0; do
{
int rIndex2 = rand() % 12; pBool[rIndex2] = 0; } while (rIndex2 == rIndex);
pBool += 12; }
I have not tested this so you need to try it a few times to make sure it produces the desired results.
|
|
|
|
|
Thanks a lot!!
Now it's working fine
Many thanks again!!
|
|
|
|
|