【C++串連資料庫】mysql

來源:互聯網
上載者:User

在“管理工具”----“資料來源”設定DSN

#pragma once#define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers#include <stdio.h>#include <tchar.h>//使用#import把動態串連庫msado15.dll匯入,組建定義ADO庫的兩個C++標頭檔:msado15.tlh和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;";//初始化COM庫::CoInitialize(NULL);//添加一個指向Connection對象的指標m_pConnection_ConnectionPtr m_pConnection(__uuidof(Connection));//創鍵Connection對象if(FAILED(m_pConnection.CreateInstance(__uuidof(Connection)))) {printf("創鍵Connection對象時出錯\n");}try{//串連資料庫m_pConnection->Open(strConnect,"","",adModeUnknown); }catch(_com_error e) {printf("串連資料庫時出錯\n");}m_pConnection->Execute(sqlCommand, NULL, 1);//執行SQL語句m_pConnection->Close(); //釋放程式佔用的COM 資源::CoUninitialize();  }

資料是插進去了,但是有錯誤

 

Error in my_thread_global_end(): 1 threads didn't exit

 

不知道咋回事,在網上搜了一下,說是mysql的問題。。。。求高手幫忙

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.