When a value is assigned to this property, the MySqlConnection is closed.
MySQL server version 4.1 or higher is required to use this option.public void UploadString(MySqlConnection myConnection) { myConnection.Unicode = true; MySqlCommand myCommand = new MySqlCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(1,'First',:BlockText)", myConnection); myCommand.Parameters.Add("BlockText",MySqlType.VarChar,50).Value = "Place here some text that requires Unicode support."; myConnection.Open(); try { Console.WriteLine(myCommand.ExecuteNonQuery()+" rows affected."); } finally { myConnection.Close(); } } public void DownloadString(MySqlConnection myConnection) { myConnection.Unicode = true; MySqlCommand myCommand = new MySqlCommand("SELECT * FROM Test.TextBlocks", myConnection); myConnection.Open(); MySqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.Default); try { while (myReader.Read()) { string myString = (string)myReader["BlockContent"]; Console.WriteLine(myString); } } finally { myReader.Close(); myConnection.Close(); } }
Public Sub UploadString(ByVal myConnection As MySqlConnection) myConnection.Unicode = True Dim myCommand As New MySqlCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(1,'First',:BlockText)", myConnection) myCommand.Parameters.Add("BlockText", MySqlType.VarChar, 50).Value = "Place here some text that requires Unicode support." myConnection.Open() Try Console.WriteLine(String.Concat(myCommand.ExecuteNonQuery(), " rows affected.")) Finally myConnection.Close() End Try End Sub Public Sub DownloadString(ByVal myConnection As MySqlConnection) myConnection.Unicode = True Dim myCommand As New MySqlCommand("SELECT * FROM Test.TextBlocks", myConnection) myConnection.Open() Dim myReader As MySqlDataReader = myCommand.ExecuteReader(CommandBehavior.Default) Try While myReader.Read() Dim myString As String = CType(myReader("BlockContent"), String) Console.WriteLine(myString) End While Finally myReader.Close() myConnection.Close() End Try End Sub