[C ++ connect to the database] MySQL

Source: Internet
Author: User
Tags dsn

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.