English


English


Knowledge base

Connect to MariaDB databases via ADO + ODBC


KB-LJW-DB-105



  




Related articles and resources




MariaDB Drivers installed on our servers Classic ASP




MariaDB
MySQL




What is MariaDB




Importing MySQL databases to MariaDB





How to manage and administer MariaDB databases




How to access MariaDB databases from Classic ASP

ASP CLASSIC
<%
'Declare MariaDB connection options/flags that may be useful with ADO + ASP Classic (non-exhaustive list)
'References & Lists (incomplete):
'https://mariadb.com/docs/connectors/mariadb-connector-odbc/mariadb-connector-odbc-guide#general-connection-parameters
'https://docs.skysql.com/Connecting%20to%20SkySQL%20DBs/Connect%20using%20ODBC/#options-bitmask
'Some connection options/flags exist and are inherited from the MySQL engine:
'https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html#codbc-dsn-option-flags
Dim CONST_DB_MARIADB__FOUND_ROWS : CONST_DB_MARIADB__FOUND_ROWS = 2
Dim CONST_DB_MARIADB__NO_PROMPT : CONST_DB_MARIADB__NO_PROMPT = 16
Dim CONST_DB_MARIADB__DYNAMIC_CURSOR : CONST_DB_MARIADB__DYNAMIC_CURSOR = 32
Dim CONST_DB_MARIADB__NO_SCHEMA : CONST_DB_MARIADB__NO_SCHEMA = 64
Dim CONST_DB_MARIADB__COMPRESSED_PROTO : CONST_DB_MARIADB__COMPRESSED_PROTO = 2048
Dim CONST_DB_MARIADB__NO_CACHE : CONST_DB_MARIADB__NO_CACHE = 1048576
Dim CONST_DB_MARIADB__FORWARD_CURSOR : CONST_DB_MARIADB__FORWARD_CURSOR = 2097152
Dim CONST_DB_MARIADB__MULTI_STATEMENTS : CONST_DB_MARIADB__MULTI_STATEMENTS = 67108864

'Declare the value (sum) of the options to be supplied to the MariaDB ODBC Driver
'(recommended list, to be customized according to your needs)
Dim dbConnOptions
dbConnOptions = CONST_DB_MARIADB__FOUND_ROWS + CONST_DB_MARIADB__NO_PROMPT

'Declare the database connection string via the MariaDB Driver
Dim dbConnString : dbConnString = "Driver={MariaDB ODBC 3.2 Driver}; Server=127.0.0.1; Charset=utf8; Port=3306; Database=dbName_abcdef; User=dbUser_test_abc123; Password=dbPw_abcdef12345; Option=" & dbConnOptions & ";"

'If you are using tables encoded in utf8mb4, add this to your connection string:
dbConnString = dbConnString & "InitStmt={SET NAMES 'utf8mb4';}"
''ALTERNATIVE: The collation type is usually already included in the table definition.
''However, you can force it for this connection if you wish:
'dbConnString = dbConnString & "InitStmt={SET NAMES 'utf8mb4' COLLATE utf8mb4_unicode_ci;}"

'Open the database connection
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.Open dbConnString
%>



MyISAM and InnoDB storage engines




Encoding and collation

Character encoding (charset)



Character collation

SQL
SELECT * FROM myTable ORDER BY myTable.champ COLLATE utf8mb4_unicode_ci;


Relationships between encoding and collation



Converting the encoding to "utf8mb4_unicode_ci"




Special cases with MariaDB


Managing DATE-type data



Default cursor








At the service of your ASP Classic





Privacy preferencesYour privacy preferences

NOTE: Your changes will be applied from the next page you will visit/load.

Your privacy is precious: we respect it.

By using this website, you consent that we use technologies such as anonymous statistics and cookies to improve your browsing experience on our site, customise content, and analyse our traffic. This anonymous information may be shared with our trusted social media and analytics partners.

  • We do not collect any nominative data.
  • We do not store any password.
  • We use a high-end secure connection.