dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlDataReader Class / GetMySqlText Method / GetMySqlText(Int32) Method
The zero-based column ordinal.
Example

In This Topic
    GetMySqlText(Int32) Method
    In This Topic
    Gets the value of the specified column as a MySqlText object.
    Syntax
    'Declaration
     
    Public Overloads Function GetMySqlText( _
       ByVal i As Integer _
    ) As MySqlText
    public MySqlText GetMySqlText( 
       int i
    )

    Parameters

    i
    The zero-based column ordinal.

    Return Value

    The value of the specified column as a MySqlText object.
    Example
    This example shows how to download a TEXT field from a table using GetMySqlBlob method.
    public void DownloadSqlText(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())
        {
          MySqlText myTextSql = myReader.GetMySqlText(myReader.GetOrdinal("BlockContent"));
          if(!myTextSql.IsNull)
          {
            Console.WriteLine(myTextSql.Value);
          }
        }
      }
      finally
      {
        myReader.Close();
        myConnection.Close();
      }
    }
    Public Sub UploadSqlText(ByVal myConnection As MySqlConnection)
      myConnection.Unicode = True
      Dim myTextSql As MySqlText = New MySqlText("This is a test text block")
      Dim myCommand As MySqlCommand = New MySqlCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(3,'First',:BlockText)", myConnection)
      myCommand.Parameters.Add("BlockText", myTextSql)
      myConnection.Open()
      Try
        Console.WriteLine(String.Concat(myCommand.ExecuteNonQuery(), " rows affected."))
      Finally
        myConnection.Close()
      End Try
    End Sub
    
    Public Sub DownloadSqlText(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 myTextSql As MySqlText = myReader.GetMySqlText(myReader.GetOrdinal("BlockContent"))
          If Not myTextSql.IsNull Then
            Console.WriteLine(myTextSql.Value)
          End If
        End While
      Finally
        myReader.Close()
        myConnection.Close()
      End Try
    End Sub
    See Also