Hello,
Is my first time when i use Visual Studio 2010 and I have some difficulties when I try to connect to Sql server and get some data.
I try to translate one VB example into VS C++, but i have some errors.
This is the code for connection to sql databse:
SqlConnection con;
SqlDataAdapter da;
SqlCommand comanda;
and this is the error : 1>c:\vc2011\t7\t7\Form1.h(102): error C2664: 'void System::Data::Common::DbCommand::Connection::set(System::Data::Common::DbConnection ^)' : cannot convert parameter 1 from 'System::Data::SqlClient::SqlConnection' to 'System::Data::Common::DbConnection ^'
How can I wrote this code "comanda.Connection = con ;" to pass this error??
Do you have some exemple in VSC 2010 with sql connection/interrogation ??
Notice the [%] symbol before the [con] variable. This is akin to the [&] used in standard/native c++ for returning the address of an object. The [%] symbol in the above code will return the 'address' (reference) to the conn object. The SqlCommand objects Connection attribute (via commanda.Connection) expects a reference to a SqlConnection object instead of an actual SqlConnection object.