dotConnect for Zoho Desk Documentation
Updating Data

You can update the Zoho Desk data either by modifying data returned by the ZohoDeskDataAdapter class and then calling its Update method or by performing corresponding DML statements (INSERT, DELETE, UPDATE) via ZohoDeskCommand.

Here is an example showing how to update Zoho Desk data using ZohoDeskDataAdapter.

using Devart.Data.ZohoDesk;
...
class Program
{

    static void Main(string[] args) {

        const string connectionString = "security token=d3c6452922f65c24b59c75aee0d0112b;";
        const string sql = "SELECT TicketID, Subject FROM Tickets";

        using (ZohoDeskConnection connection = new ZohoDeskConnection(connectionString)) {

            connection.Open();
            DataTable table = new DataTable("Tickets");

            using (ZohoDeskCommand command = connection.CreateCommand()) {

                command.CommandText = sql;
                using (ZohoDeskDataAdapter adapter = new ZohoDeskDataAdapter(command)) {

                    adapter.Fill(table);

                    adapter.UpdateCommand = new ZohoDeskCommand("UPDATE Tickets SET Subject = @subject WHERE TicketID = @id", connection);

                    adapter.UpdateCommand.Parameters.Add("id", DbType.String).SourceColumn = "TicketID";
                    adapter.UpdateCommand.Parameters["id"].SourceVersion = DataRowVersion.Original;
                    adapter.UpdateCommand.Parameters.Add("subject", DbType.String).SourceColumn = "Subject";

                    DataRow firstrow = table.Rows[0];
                    firstrow["Subject"] = "sample subject 1";
                    Console.WriteLine(adapter.Update(table));
                }
            }
            Console.WriteLine("Rows after update.");

            foreach (DataRow row in table.Rows) {
                Console.WriteLine("{0}\t{1}", row[0], row[1]);
            }
        }
        Console.ReadKey();
    }

}
Imports Devart.Data.ZohoDesk
...
Module Module1

    Sub Main()

        Const connectionString As String = "security token=d3c6452922f65c24b59c75aee0d0112b;"
        Const sql As String = "SELECT TicketID, Subject FROM Tickets"

        Using connection As New ZohoDeskConnection(connectionString)

            connection.Open()
            Dim table As New DataTable("Accounts")

            Using command As ZohoDeskCommand = connection.CreateCommand()

                command.CommandText = sql
                Using adapter As New ZohoDeskDataAdapter(command)
                    adapter.Fill(table)

                    adapter.UpdateCommand = New ZohoDeskCommand("UPDATE Tickets SET Subject = @subject WHERE TicketID = @id", connection)

                    adapter.UpdateCommand.Parameters.Add("id", DbType.String).SourceColumn = "TicketID"
                    adapter.UpdateCommand.Parameters("id").SourceVersion = DataRowVersion.Original
                    adapter.UpdateCommand.Parameters.Add("subject", DbType.String).SourceColumn = "Subject"

                    Dim firstrow As DataRow = table.Rows(0)
                    firstrow("Subject") = "sample subject 1"
                    Console.WriteLine(adapter.Update(table))

                    Console.WriteLine("Rows after update.")
                    For Each row As DataRow In table.Rows
                        Console.WriteLine(row(0).ToString() & vbTab & row(1))
                    Next
                End Using
            End Using
        End Using
        Console.ReadKey()
    End Sub

End Module

The following example updates Zoho Desk data using ZohoDeskCommand.

using Devart.Data.ZohoDesk;
...
class Program
{

    static void Main(string[] args) {

        const string connectionString = "security token=d3c6452922f65c24b59c75aee0d0112b;";
        const string sql = "UPDATE Tickets SET Status = 'Open' WHERE \"Subject\" = 'sample subject 1'";

        using (ZohoDeskConnection connection = new ZohoDeskConnection(connectionString)) {

            connection.Open();
            using (ZohoDeskCommand command = connection.CreateCommand()) {

                command.CommandText = sql;
                Console.WriteLine(command.ExecuteNonQuery());
            }
        }
        Console.ReadKey();
    }
}
Imports Devart.Data.ZohoDesk
...
Module Module1

    Sub Main()

        Const connectionString As String = "security token=d3c6452922f65c24b59c75aee0d0112b;"
        Const sql As String = "UPDATE Tickets SET Status = 'Open' WHERE ""Subject"" = 'sample subject 1'"

        Using connection As New ZohoDeskConnection(connectionString)

            connection.Open()
            Using command As ZohoDeskCommand = connection.CreateCommand()

                command.CommandText = sql
                Console.WriteLine(command.ExecuteNonQuery())
            End Using
        End Using
        Console.ReadKey()
    End Sub

End Module

See Also

Entity Framework  | Retrieving Data