Oracle 5.0 Reference Manual page 1917

Table of Contents

Advertisement

Even when using the
This section describes how to connect to MySQL using the
20.2.5.2. Creating a Connector/Net Connection String
The
MySqlConnection
several key/value pairs, separated by semicolons. In each key/value pair, the option name and its
corresponding value are joined by an equal sign. For the list of option names to use in the connection
string, see
Section 20.2.6, "Connector/Net Connection String Options
The following is a sample connection string:
Server=127.0.0.1;Uid=root;Pwd=12345;Database=test;
In this example, the
127.0.0.1, with a user name of
statements will be the
20.2.5.2.1. Opening a Connection
Once you have created a connection string it can be used to open a connection to the MySQL server.
The following code is used to create a
open the connection.
Connector/Net can also connect using the native Windows authentication plugin. See
"Using the Windows Native Authentication Plugin"
You can further extend the authentication mechanism by writing your own authentication plugin. See
Section 20.2.5.6, "Writing a Custom Authentication Plugin"
Visual Basic Example
Dim conn As New MySql.Data.MySqlClient.MySqlConnection
Dim myConnectionString as String
myConnectionString = "server=127.0.0.1;" _
Try
conn.ConnectionString = myConnectionString
conn.Open()
Catch ex As MySql.Data.MySqlClient.MySqlException
MessageBox.Show(ex.Message)
End Try
C# Example
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=127.0.0.1;uid=root;" +
"pwd=12345;database=test;";
Connector/Net Programming
MySqlHelper
object is configured using a connection string. A connection string contains
MySqlConnection
root
database.
test
Note
Using the '@' symbol for parameters is now the preferred approach, although
the old pattern of using '?' is still supported. To avoid conflicts when using
the '@' symbol in combination with user variables, see the
connection string option in
Variables
Connection String Options
option has now been deprecated.
& "uid=root;" _
& "pwd=12345;" _
& "database=test;"
class, a
MySqlConnection
MySqlConnection
object is configured to connect to a MySQL server at
and a password of 12345. The default database for all
Section 20.2.6, "Connector/Net
Reference". The
object, assign the connection string, and
MySqlConnection
for details.
for details.
1897
object is created by the helper class.
object.
Reference".
Allow User
connection string
Old Syntax
Section 20.2.5.5,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents