Connector/Net Programming
1901
using MySql.Data.MySqlClient;
namespace ConsoleApplication2
{
class Program
{
private static void DisplayData(System.Data.DataTable table)
{
foreach (System.Data.DataRow row in table.Rows)
{
foreach (System.Data.DataColumn col in table.Columns)
{
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
}
Console.WriteLine("============================");
}
}
static void Main(string[] args)
{
string connStr = "server=localhost;user=root;database=world;port=3306;password=******;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
Console.WriteLine("Connecting to MySQL...");
conn.Open();
DataTable table = conn.GetSchema("MetaDataCollections");
//DataTable table = conn.GetSchema("UDF");
DisplayData(table);
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.WriteLine("Done.");
}
}
}
Further information on the
GetSchema()
method and schema collections can be found in the
Microsoft .NET documentation
.
20.2.5.3. Using MySqlCommand
A
MySqlCommand
has the
CommandText
and
CommandType
properties associated with it. The
CommandText
will be handled differently depending on the setting of
CommandType
.
CommandType
can be one of:
1. Text - A SQL text command (default)
2. StoredProcedure - The name of a Stored Procedure
3. TableDirect - The name of a table (new in Connector/Net 6.2)
The default
CommandType
,
Text
, is used for executing queries and other SQL commands. Some
example of this can be found in the following section
Section 20.2.4.1.2, “The MySqlCommand Object”
.
If
CommandType
is set to
StoredProcedure
, set
CommandText
to the name of the Stored Procedure
to access.
If
CommandType
is set to
TableDirect
, all rows and columns of the named table will be returned
when you call one of the Execute methods. In effect, this command performs a
SELECT *
on the table
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...