exception with ExecuteNonQuery();

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply

exception with ExecuteNonQuery();

Post by theud » Mon 20 Dec 2004 16:10

HI. I have this error
"non handled exception 'System.InvalidOperationException' incorelab.mysql.dll

added information : Connection property has not been initialized"

with this simple VC++.net program, at the line myCommand->ExecuteNonQuery();

#include "stdafx.h"

using namespace System;
using namespace System::Data;
using namespace CoreLab::MySql;

int main() {
String* q="INSERT INTO `accor` ( `date` , `open` , `high` , `low` , `close` ) VALUES ('2004-05-01', '10', '1', '1', '1')";
MySqlCommand *myCommand = new MySqlCommand(q);
MySqlConnection * cntd= new MySqlConnection("User=root;Host=localhost;Port=3306;Database=td");
return 0;

Could you explained it to me. Strangely, it worked once, and then never ....

Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: exception with ExecuteNonQuery();

Post by Oleg » Tue 21 Dec 2004 09:52

You should add this row to your code:

Code: Select all

 myCommand->Connection = cntd
Just it was specified in the exception: 'Connection property has not been initialized.'

Post Reply