VB6 connecting MySQL Database

Source: Internet
Author: User
Tags odbc

Visual VB6 less information, it took a long time to write a query statement

First download the driver, I am win7 x64 do not know just started to download a 5.1 x64 driver why not connected, the total hint can not find the driver, download 5.3 32 bit after normal

http://dev.mysql.com/downloads/connector/odbc/

Dimcn as NewADODB. ConnectionDimRs as NewADODB. Recordset'defining database connection string variablesDimStrcn as String'defining database connection parameter variablesDimDb_host as StringDimDb_user as StringDimDb_pass as StringDimDb_data as StringDimCmd as NewAdodb.command'defining SQL Statement variablesDimSql as String'Initializing database connection variablesDb_host ="127.0.0.1"Db_user="Root"Db_pass=""Db_data="Family"STRCN="driver={mysql ODBC 5.3 Unicode DRIVER};"& _         "server="& Db_host &";"& _         "database="& Db_data &";"& _         "uid="& Db_user &"; Pwd="& Db_pass &";"& _         "option=3;stmt=set NAMES UTF8"         'connecting to a database'CN. Open STRCN'set this property so that the RecordCount and AbsolutePage properties are available'CN. CursorLocation = adUseClient'Rs. Open "Tb_sys_emp", CN, adOpenKeyset, adLockOptimistic'Rs. MoveFirst'Do While Rs. EOF = False'Debug.Print Rs. Fields ("Emp_name")'Rs. MoveNext'Loop'Rs. CloseCN. Open STRCNSetCmd. ActiveConnection =Cncmd.commandtext="Select Emp_name from Tb_sys_emp"Cmd.commandtype=Adcmdtextcmd.commandtimeout= theSetrs =cmd. Executers.movefirst Do  whileRs. EOF =FalseDebug.Print Rs. Fields ("Emp_name") Rs. MoveNextLoopRs. Closedebug.print list. Count

VB6 connecting MySQL Database

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.