In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces you how to use ADO to connect to mysql, the content is very detailed, interested friends can refer to, hope to be helpful to you.
First, create databases, create tables, and insert data
> show databases
> create database mydb
> user mydb
> create table mytable (id int (4) not null primary key auto_increment,name char (20) not null, sex int (4) not null default'0')
> insert into mytable (id, name, sex) values (1, 'aaa', 0)
> insert into mytable (name, sex) values ('aaa', 0)
>
2. ADO connects to mysql database
2.1 install the mysql driver
Driver name: mysql-connector-odbc-5.2.5-win32.msi
Download address: http://dev.mysql.com/downloads/connector/odbc/
2.2 configure odbc data sources
Control Panel-> system and Security-> Administrative tools-> data Source ODBC-> user DSN-> add-> MySQL ODBC 5.2 ANSI Driver
Driver and ODBC data source, must be consistent: http://blog.csdn.net/kanguolaikanguolaik/article/details/9497329
2.3 Program connects to mysql database
# include # include # include using namespace std;#import "C:\ Program Files\ Common Files\ System\ ado\ msado15.dll" no_namespace rename ("EOF", "adoEOF") int main (int argc, char * argv []) {CoInitialize (NULL); / / Connect _ ConnectionPtr pConn; pConn.CreateInstance (_ uuidof (Connection)); try {HRESULT hr = pConn- > Open ("DSN=MySQL-ODBC;server=localhost;database=mydb" "," root "," love ", adModeUnknown);} catch (_ com_error & e) {coutadoEOF) {_ variant_t vID = pRecord- > GetCollect (_ variant_t ((long) 0)); _ variant_t vName = pRecord- > GetCollect (" name "); _ variant_t vSex = pRecord- > GetCollect (" sex ") Cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.