Note that there are some explanatory texts on larger screens.

plurals
  1. POVisual C++ (VS13) and MySQL connection with GUI (CLR)
    text
    copied!<p>I need to make a "simple" c++ appliaction using Visual c++ that can connect to a database and get data from it and display it as either a text box or label.</p> <p>I have dowloaded <code>boost</code> and the <code>C++ Connector</code> from mysql.com, and included it to the project file like this:</p> <p>The boost folder (boost_1_55_0) and the include dirictory of the connector in the Additional Dependancies in C/C++ General, and the Subsystem is Windows (/SUBSYSTEM:WINDOWS).</p> <p>It fails to build, no matter what I try...</p> <p>Here is the main.cpp:</p> <pre><code>#include "MyForm.h" #include &lt;stdlib.h&gt; #include "mysql_connection.h" #include "mysql_driver.h" #include &lt;cppconn/driver.h&gt; #include &lt;cppconn/exception.h&gt; #include &lt;cppconn/resultset.h&gt; #include &lt;cppconn/statement.h&gt; using namespace std; using namespace sql; using namespace System; using namespace System::Windows::Forms; void sqlfx() { Driver *driver; Connection *con; Statement *stmt; ResultSet *res; /* Create a connection */ driver = get_driver_instance(); con = driver-&gt;connect("localhost", "root", ""); /* Connect to the MySQL test database */ con-&gt;setSchema("test"); stmt = con-&gt;createStatement(); res = stmt-&gt;executeQuery("SELECT 'Hello World!' AS _message"); while (res-&gt;next()) { /*cout &lt;&lt; "\t... MySQL replies: ";*/ /* Access column data by alias or column name */ /*cout &lt;&lt; res-&gt;getString("_message") &lt;&lt; endl;*/ /*cout &lt;&lt; "\t... MySQL says it again: ";*/ /* Access column fata by numeric offset, 1 is the first column */ /*cout &lt;&lt; res-&gt;getString(1) &lt;&lt; endl;*/ } delete res; delete stmt; delete con; } [STAThread] void Main(array&lt;String^&gt;^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Project1::MyForm form; Application::Run(%form); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload