The connection string contains initialization information that is passed as a parameter to the data source. The connection string is parsed immediately after setting. A syntax error generates a Run-time exception, but you can discover additional errors only if the data source validates the information in the
C # MySQL database connection method bitsCN.com
C # How to connect to the MySQL database
1. use MySQLDriverCS to connect to the MySQL database. download and install MySQLDriverCS first. address:
Http://sourceforge.net/projects/mysqldrivercs
Find MySQLDriver. dll in the installation folder, and add the MySQLDriver. dll
"; Public Static stringTextprovider ="microsoft.jet.oledb.4.0"; Public Static stringOracleprovider ="Msdaora"; Public Static stringMysqlprovider ="Mysqlprov"; Public Static stringIbmdb2provider ="Db2oledb"; Public Static stringSibprovider ="Sibprovider"; Public Static stringAdaptiveserveranywhereprovider ="Asaprov"; Public Static stringAdaptiveserverenterpriseprovider ="Sybase ASE OLE DB Provider"; Public Static stringVisualfoxproprovider ="Vfpoledb"; } Public structDbdriver { Public
new data source added. Open Delphi 7, Place Tadoconnection, Tadoquery, Tdatasource, and Tdbgrid on the form, associate with each other, configure the Tadoconnection connection string, "provider" select "Microsoft OLE DB Provider for ODBC Drivers ", Next, select" Use data source name ", drop-down to select the data source that you just configured, other than fill
. Press the F5 key to compile and run the project, and then click Button1.
8. Type the appropriate information in the Data Link Properties dialog box, and make sure that the Allow Password Save check box is selected.
9. Click Test Connection.
10. Click OK. If the connection test for the data link succeeds, a connection is made to the database and a message box is
Label:When accessing the MySQL database, if you set up a connection pool in the connection string and set the connection pool size, you can significantly increase the speed of accessing the database when you test it.Connection string:Connectionstrings>pooling=true; Max Pool
ODBC for Oracle}; server = oracleserver. World;Uid = username; Pwd = asdasd ;"Ii. Old Version:"Driver = {Microsoft ODBC driver for Oracle}; connectstring =Oracleserver. World; uid = myusername; Pwd = mypassword ;"B. OLE DB, oledbconnection (. NET)I. Standard Security:"Provider = msdaora; Data Source = myoracledb; user id = username;Password = asdasd ;"Note: The above is the MS driver, and the following is
Delphi 7 connection MySQL 5.5.151.ODBC modeMust first have MySQL ODBC driver, I download is full install version, including MySQL server, various supported connection, Workbench, sample
NULL, `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`actor_id`), KEY `idx_actor_last_name` (`last_name`) ) ENGINE =FEDERATED CONNECTION='mysql://root:123456@127.0.0.1:3306/sakila/actor';
Note: The locally created table must be consistent with the remote table. Select ENGINE = FEDERATED as the local storage ENGINE.
The
, database connection, point "test" to test the connection, as shown in:When you click "OK", you will see a new data source added. Open Delphi 7, Place Tadoconnection, Tadoquery, Tdatasource, and Tdbgrid on the form, associate with each other, configure the Tadoconnection connection string, "provider" select "Microsoft
Example | data | database | database connection | String using DSN's database connection string example:
MS Sql/mysql/postgresql
"Dsn=dsnname"
Do not use DSN database connection string
, tdatasource the query property to associate the actual name of the control on the Tadoquery, the order of the above, and so on), Configure the connection string for Tadoconnection, "provider" select "Microsoft OLE DB Provider for ODBC Drivers", Next, select "Use data source name", drop down to select the data source that you just configured, the other is not fi
. Remote Data Connection
Driver={MySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase; User=myUsername;Password=myPassword;
3. Special TCP/IP Port connection
Note: The default port of this Driver is 3306. If it is not specified in the MySQL connection
Example of a database connection string using DSN:
MS Sql/mysql/postgresql
"Dsn=dsnname"
Do not use DSN database connection string Example:
MS Access
via OLE DB:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:somepathmydb.mdb; "
MS SQL
Through
=yes; Database Mirroring 10.0}; Server = myserveraddress; Failover_partner = Mymirrorserveraddress;database = MyDataBase; Trusted_Connection = yes; V.. NET Framework Data Provider for ODBC type:. NET Framework Wrapper Class Libraryuse: System.Data.Odbc.OdbcConnectionVendor: Microsoft Bridge to SQL Native Client 10.0 ODBC Driver The following statement is just an example of the different
MySQL can be connected to the Web in two ways via PHP, a MySQL-related function via PHP, and an ODBC-related function through PHP.
The relevant functions are as follows:
MySQL function
Mysql_affected_rows: Gets the number of columns affected by MySQL last operation.
Mysql_c
MySQL can be connected to the Web in two ways via PHP, a MySQL-related function via PHP, and an ODBC-related function through PHP.
The relevant functions are as follows:
MySQL function
Mysql_affected_rows: Gets the number of columns affected by MySQL last operation.
Mysql_cl
OracleXE standard connection OracleXE (or OracleDatabase10gExpressEdition) is a simple and free version. The following syntax is used: Driver (OracleinXEClient); dbq111.21.31.99: 1521XE; UidmyUsername; PwdmyPassword; the connection mode for new ODBC versions is as follows:
Oracle XE standard connection Oracle XE (or Or
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.