|
Thilek wrote: is there any others way i can connect to mysql using different classes or connecters
The one from MySQL, which you have used is the correct. Here[^] you get connection strings. Make sure you are using a valid format and the server address you have provided is accessible from where you are connecting.
|
|
|
|
|
after i change the string value to :
MySqlConnection ^conDatabase = gcnew MySqlConnection("Server=sql304.byetcluster.com;Database='speed_2972829_worm'; Uid='username' ;Pwd='password'; Protocol=pipe; Port=3306; CharSet=UTF8");
i get this error :
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: Reading from the stream has failed.
i am confused...hmm.. can help me ya ?
|
|
|
|
|
Thilek wrote: Reading from the stream has failed.
Looks like it is a bug in connector. See here[^]. Not sure it got fixed
|
|
|
|
|
well i think the server dont support remote login from .net.. with php no problem..
|
|
|
|
|
hi guys,
i been working on a worm scanner lately... i got a funtion that list all the files in a directory.. but the the filename is on vector but i need to list them in a list box. but when i compile there is no problem but when i run it there is problem showing :
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
Below is my coding :
if (ListFiles(directory, L"*", files)) {
for (vector<wstring>::iterator it = files.begin();
it != files.end();
++it) {
std::string filename = WStringToString(it->c_str());;
std::string s=filename;
String ^someString= gcnew String(s.c_str());
listBox1->Items->Add(String::Format(someString,"\n"));
// wcout << it->c_str() << endl;
}
}
Kidly help me plz guys... the program must make the filenames to be shown in the list ya in anyways, even its not in System::String as long its showed there is gud enough... i been working on this 3 days but nvr solved it.....
Regards,
Thilek
|
|
|
|
|
Hi,
String::Format requires the place holders ({0},{1}..) in the format string to work. You have used String::Format with an invalid format string. I can't see any need of String::Format here. As I understand, you need to add a newline character to the string. It can be done like
listBox1->Items->Add(String::Concat(someString,"\n")); BTW, a list shows one item in a row. So why do you need to add line break?
|
|
|
|
|
really thanks a lot my fren. its really helped me. about the newlinew was a silly mistake done by me after sitting and breaking my head for 3 days to solve it...
Thanks alot. God bless you.
|
|
|
|
|
You are welcome.
|
|
|
|
|
Why is this code throwing exception
gameBoard->gameBtns = gcnew array<Button^>(GameBoard::TOTAL_BOXES);
for each(Button^ btn in gameBoard->gameBtns)
btn->Enabled = true;
where TOTAL_BOXES is defined as 9
but this code doesn't
Button^ temp = gcnew Button();
temp->Enabled = true;
|
|
|
|
|
Hi,
Ahmed Manzoor wrote: Button^ temp = gcnew Button();
creates a button, so you can operate on it.
Ahmed Manzoor wrote: gameBtns = gcnew array<button^>(GameBoard::TOTAL_BOXES);
Does not generate any buttons, all it does is generate an array that will be able to hold some buttons.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
so I'll have to generate each button individually?
|
|
|
|
|
Ahmed Manzoor wrote: so I'll have to generate each button individually?
Yes. You did it when you needed one, what makes you think you don't have to when you want a lot of them?
BTW: array elements are initialized to null; you only need to create as many buttons as you need, you
can leave the non-essential elements, if any, at null.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I want to know the difference between managed and unmanged code..
Thanks
vikas da
|
|
|
|
|
|
Hi,
I have a C++ library app which talks to a C++ server and I am creating a vectorje of my custom class objects. But my Cpp/CLI app(which interacts with native C++ ), throws a memory violation error when I try to return my custom class obj vector.
Code Sample -
In my native C++ class -
std::vector<a> GetStuff(int x)
{
-- do stuff
std::vector<a> vec;
A a;
vec.push_back(a);
--- push more A objs
return vec;
}
In my Cpp/CLI class
public void doStuff()
{
std::vector<a> vec;
vec = m_nativeCpp->GetStuff(4); // where nativeCpp is a dynamically allocated class in nativecpp DLL, the app throws up a memory violation error here!
}
Anything I am missing here ?What should be the ideal way to return such an array -
Regards
Amit </a></a></a>
|
|
|
|
|
Type A is created on stack and this may be the problem. Have you tried to allocate it on heap and let vector hold a pointer to it. I believe that will solve the issue. I haven't tried this, but a wild guess.
Member 5703905 wrote: throws up a memory violation error
What is the exact error message?
|
|
|
|
|
Okay, but I wanted to convey that nativeC++ DLL and Cpp/CLI DLL are in diff projects. Not sure if it is a nice idea to return a ptr from unmanaged project to managed cpp/cli project.
N a v a n e e t h wrote: What is the exact error message?
An unhandled exception of type 'System.AccessViolationException' occurred in CLIConsole.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Thanks
Amit
|
|
|
|
|
Member 5703905 wrote: Not sure if it is a nice idea to return a ptr from unmanaged project to managed cpp/cli project.
It's fine in C++/CLI. Native objects will be on the native heap, managed objects
will be on the managed heap. If you need to hold the pointer in a managed object, you
can use the IntPtr type.
If you expect to allocate the native object in one DLL and free it in another DLL, you'll
want to make sure both DLLs are sharing the same CRT library (DLL).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
In VC++ I want to execute .exe using ShellExecute command. But ShellExecute works for hardcoded file names. Suppose that if I want to pass a file selected by the user i.e.this->openFileDialog1->FileName in ShellExecute, how should I do that?
::ShellExecute(NULL, L"open", L"C:\\play.bat", this->openFileDialog1->FileNameNULL, SW_SHOW);
gives error : cannot convert from 'System::String ^' to 'LPCTSTR'
even using ((LPCTSTR)this->openFileDialog1->FileName)doesn help
|
|
|
|
|
|
HI
I need hook events of keyboard in my app, this is made in managed c++, i did one dll in c++ for hook keyboard and this run good.
first i did simple app in C for test my dll and using SetWindowsHookEx
BOOL HazHook()
{
HOOKPROC hkprcSysMsg;
HPROC hkprcSysMsg2;
HINSTANCE hinstDLL;
HHOOK hhookSysMsg;
hinstDLL = LoadLibrary((LPCTSTR) "keyboard.dll");
if ( hinstDLL != NULL)
{
OutputDebugString ( "1> OK\n");
hkprcSysMsg2 = (HPROC)GetProcAddress(hinstDLL, "_keyboardHookProc@12");
if ( hkprcSysMsg2 != NULL)
{
OutputDebugString ( "2> OK\n");
// LocalhPrevInstance is hPrevInstance of WinMain app.
hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD_LL,hkprcSysMsg2,hinstDLL,LocalhPrevInstance); // original
if( hhookSysMsg != NULL)
{
OutputDebugString ( "3> OK\n");
return TRUE;
}
else OutputDebugString ( "3> FAIL\n");
}else OutputDebugString ( "2> FAIL\n");
}else OutputDebugString ( "1> FAIL\n");
return FALSE;
}
The problems start whemn I need use SetWindowsHookEx in Managad C++, I try inport API but the conversion of rates I not know, HOOKPROC, HINSTANCE , DWORD is unsigned int
[DllImport("user32.dll")]
static int SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod,DWORD dwThreadId);
Other try is using unamanged C++
#include "stdafx.h"
#pragma unmanaged
#include <windows.h>
#include <stdio.h>
typedef LRESULT (CALLBACK *HPROC)(int , WPARAM , LPARAM );
bool lalaLoadDllKeyboard()
{
HOOKPROC hkprcSysMsg;
HPROC hkprcSysMsg2;
HINSTANCE hinstDLL;
HHOOK hhookSysMsg;
hinstDLL = LoadLibrary( "keyboard.dll");
if ( hinstDLL != NULL)
{
hkprcSysMsg2 = (HPROC)GetProcAddress(hinstDLL, "_keyboardHookProc@12");
if ( hkprcSysMsg2 != NULL)
{
OutputDebugString ( "2> OK\n");
//hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD_LL,hkprcSysMsg2,hinstDLL,LocalhPrevInstance); // original
hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD_LL,hkprcSysMsg2,hinstDLL,0); // original
if( hhookSysMsg != NULL)
{
OutputDebugString ( "3> OK\n");
return true;
}
}
}
return false;
}
#pragma managed
But to compile errors:
1>------ Operación Generar iniciada: proyecto: WinFormsHookKeyboard, configuración: Debug Win32 ------
1>Vinculando...
1>codeunamanged.obj : error LNK2019: símbolo externo _SetWindowsHookExA@16 sin resolver al que se hace referencia en la función "bool __cdecl lalaLoadDllKeyboard(void)" (?lalaLoadDllKeyboard@@YA_NXZ)
Any idea ??
Thank
|
|
|
|
|
Kar98 wrote: I try inport API but the conversion of rates I not know, HOOKPROC, HINSTANCE , DWORD is unsigned int
pinvoke.net: SetWindowsHookEx()[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I'm new in Visual C++.I want to convert row elements from two dimensional array to one dimensional arrays.I wrote Visual C++ function to do this.This function has only one input parameter.Input parameter is two dimensional array.Firstly I tried to copy first row elements of input two dimensional array to one dimensional array in this function.One dimensional array will have been output parameter of function.But it didn't work.
The code is below:
// Temp is one dimensional array its length is 512
// Input paremeter is two dimensional array its width is 512 ,height is 512
// I want to copy first row elements of input two dimensional array to one dimensional array.
array^ fonksiyon (array<double,2>^dizi )// The function
{ array^ temp=gcnew array(512);
Array::Copy(dizi,temp,512);
return temp;// return one dimesional array
}
Could you please help me ? Best regards...
|
|
|
|
|
Hey everyone... I need some assistance getting an image from a string.
I have an RTF text box into which a user can paste an image. However, I'd like to take this image out of the RTF and store is elsewhere. The System.Drawing.Image class has a function called FromString but I can't seem to figure out how to correctly use it. I've also looked at the System.Drawing.ImageConverter class but that hasn't helped either.
Can anyone tell me how to get this image out of the rtf and into a bitmap object?
Thanks,
Sam.
|
|
|
|
|
OO... i mean the imageconverter class has a function called "FromString" - not the image class...
|
|
|
|