X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=web%2Fmysql;h=2449bc1f4e75b90e95c632205e06b28339a6f636;hb=e9d9e938eaba9b500cc322334aa2688bac01f6a9;hp=23a83129117c0dd3bb664828c0aec4fcae4e0835;hpb=af653b483b9bf8247c85ec0fcfa984e082d1718d;p=mono.git diff --git a/web/mysql b/web/mysql index 23a83129117..2449bc1f4e7 100755 --- a/web/mysql +++ b/web/mysql @@ -14,30 +14,23 @@ -
Exploring MySQL - in the Microsoft .NET Environment is an article - by Mr. Venu who is a MySQL AB developer. - -
Testing for Mono's Mono.Data.MySql and ByteFX's ByteFX.Data.MySQLClient is below. + in the Microsoft .NET Environment is a nice article to read. ** Current Status @@ -45,7 +38,7 @@
using System; using System.Data; - using ByteFX.Data.MySQLClient; + using ByteFX.Data.MySqlClient; public class Test { @@ -167,7 +130,8 @@ "User ID=myuserid;" + "Password=mypassword;"; IDbConnection dbcon; - dbcon = new MySQLConnection(connectionString); + dbcon = new MySqlConnection(connectionString); + dbcon.Open(); IDbCommand dbcmd = dbcon.CreateCommand(); // requires a table to be created named employee // with columns firstname and lastname @@ -181,8 +145,8 @@ dbcmd.CommandText = sql; IDataReader reader = dbcmd.ExecuteReader(); while(reader.Read()) { - string FirstName = reader["firstname"]; - string LastName = reader["lastname"]; + string FirstName = (string) reader["firstname"]; + string LastName = (string) reader["lastname"]; Console.WriteLine("Name: " + FirstName + " " + LastName); } @@ -200,18 +164,9 @@
mcs TestExample.cs -r System.Data.dll \ -r ByteFX.Data.dll --
- mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \ - TestExample.cs \ - -lib:C:/cygwin/home/MyHome/mono/install/lib \ - -r System.Data.dll -r ByteFX.Data.dll
- "Server=hostname;" + - "Database=database;" + - "User ID=username;" + - "Password=password" - (or) - "host=hostname;" + - "dbname=database;" + - "user=username;" + - "passwd=password" -- -
- using System; - using System.Data; - using Mono.Data.MySql; - - public class Test - { - public static void Main(string[] args) - { - string connectionString = - "Server=localhost;" + - "Database=test;" + - "User ID=myuserid;" + - "Password=mypassword;"; - IDbConnection dbcon; - dbcon = new MySqlConnection(connectionString); - IDbCommand dbcmd = dbcon.CreateCommand(); - // requires a table to be created named employee - // with columns firstname and lastname - // such as, - // CREATE TABLE employee ( - // firstname varchar(32), - // lastname varchar(32)); - string sql = - "SELECT firstname, lastname " + - "FROM employee"; - dbcmd.CommandText = sql; - IDataReader reader = dbcmd.ExecuteReader(); - while(reader.Read()) { - string FirstName = reader["firstname"]; - string LastName = reader["lastname"]; - Console.WriteLine("Name: " + - FirstName + " " + LastName); - } - // clean up - reader.Close(); - reader = null; - dbcmd.Dispose(); - dbcmd = null; - dbcon.Close(); - dbcon = null; - } - } --
- mcs TestExample.cs \ - -r System.Data.dll \ - -r Mono.Data.MySql.dll --
- mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \ - TestExample.cs \ - -lib:C:/cygwin/home/MyHome/mono/install/lib \ - -r System.Data.dll \ - -r Mono.Data.MySql.dll --
-mono TestExample.exe --