choose "Administrative Tools"> "Data Source" to set DSN.
# pragma once # define win32_lean_and_mean // exclude rarely-used stuff from Windows headers # include
# include
// use # import to import the dynamic Connection Library msado15.dll and generate two C ++ header files defining the ADO Library: msado15.tlh and ado15.tli # import "C: \ Program Files \ common files \ System \ ADO \ msado15.dll "no_namespace Rename (" EOF "," endoffile ") void main () {char * sqlcommand = "insert into student values (20120822, 'c ++ conect ');"; _ bstr_t strconnect = "DSN = mysql5; database = test; uid = root; pwd = 890531; "; // initialize the com Library: coinitialize (null); // Add a pointer to the connection object m_pconnection_connectionptr m_pconnection (_ uuidof (connection )); // If (failed (m_pconnection.createinstance (_ uuidof (connection) {printf ("An error occurred while creating the connection object \ n ");} try {// connect to the database m_pconnection-> open (strconnect, "", "", admodeunknown);} catch (_ com_error E) {printf ("error connecting database \ n");} m_pconnection-> execute (sqlcommand, null, 1); // execute the SQL statement m_pconnection-> close (); // release the com resource occupied by the
Program : couninitialize () ;}
The data is inserted, but there is an error.
Error in my_thread_global_end (): 1 threads didn't exit
I don't know what's going on. I searched the internet and said it was a MySQL problem .... Please help