First, downloadMySQL connector/ODBC 3.51 downloads
Download the package and go to Control Panel> Management Tools> data source (ODBC). Double-click it and click Add,
Select MySql ODBC 3.51 driver
Then, the MySQL parameter configuration window is displayed, as shown below:
After entering the relevant parameters, click test. If the connection is successful, confirm the configuration.
Below is C #Code
Code
//Add namespace
UsingSystem. Data. ODBC;
Code
Private Void Page_load ( Object Sender, system. eventargs E)
{
// Place user code here to initialize the page
String Strconn = " Driver = {MySQL ODBC 3.51 driver}; server = 192.168.1.105; database = mydb; user = Joe; Password = AST; option = 3; " ;
String SQL = " Select title, tid from Info " ;
Odbcconnection myconnection = New Odbcconnection (strconn );
Odbccommand mycommand = New Odbccommand (SQL, myconnection );
Myconnection. open ();
Dropdownlist1.datasource = Mycommand. executereader (commandbehavior. closeconnection );
Dropdownlist1.datatextfield = " Title " ;
Dropdownlist1.datavaluefield = " TID " ;
Dropdownlist1.databind ();
Myconnection. Close ();
}
MySQL connector/ODBC 3.51 (myodbc 3.51)
Remote database connection to MySQL
Code
Driver={MySQL ODBC3.51Driver}; server=Data.domain.com; Database=Mydatabase; User=Myusername; Password=Mypassword; Option=3;
PS: in Visual Studio 2003, MySQL connector/ODBC 5.1 has the following exception:
"Error [hy000] [MySQL] [ODBC 5.1 Driver] Access denied for user 'odbc '@ '192. 168.1.104' (using password: Yes)"
Test environment of this post:
OS: Windows xp2
Development Environment: Visual Studio 2003 Asp.net 1.1
MySQL database server: Fedora Core 9 Linux
MySQL version: MySQL ver 14.12 distrib 5.0.51a, for Redhat-Linux-GNU (i386) using Readline 5.0