In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.