dotConnect for Zoho CRM Documentation
In This Topic
    Updating Data
    In This Topic

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

    Here is an example showing how to update Zoho CRM data using ZohoDataAdapter.

    using Devart.Data.Zoho;
    ...
    class Program
    {
    
        static void Main(string[] args) {
    
            const string connectionString = "security token=d3c6452922f65c24b59c75aee0d0112b;";
            const string sql = "SELECT AccountID, \"Account Name\" FROM Accounts";
    
            using (ZohoConnection connection = new ZohoConnection(connectionString)) {
    
                connection.Open();
                DataTable table = new DataTable("Accounts");
    
                using (ZohoCommand command = connection.CreateCommand()) {
    
                    command.CommandText = sql;
                    using (ZohoDataAdapter adapter = new ZohoDataAdapter(command)) {
    
                        adapter.Fill(table);
    
                        adapter.UpdateCommand = new ZohoCommand("UPDATE Accounts SET \"Account Name\" = @name WHERE AccountID = @id", connection);
    
                        adapter.UpdateCommand.Parameters.Add("id", DbType.String).SourceColumn = "AccountID";
                        adapter.UpdateCommand.Parameters["id"].SourceVersion = DataRowVersion.Original;
                        adapter.UpdateCommand.Parameters.Add("name", DbType.String).SourceColumn = "Account Name";
    
                        DataRow firstrow = table.Rows[0];
                        firstrow["Account Name"] = "sample name 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.Zoho
    ...
    Module Module1
    
        Sub Main()
    
            Const connectionString As String = "security token=d3c6452922f65c24b59c75aee0d0112b;"
            Const sql As String = "SELECT AccountID, ""Account Name"" FROM Accounts"
    
            Using connection As New ZohoConnection(connectionString)
    
                connection.Open()
                Dim table As New DataTable("Accounts")
    
                Using command As ZohoCommand = connection.CreateCommand()
    
                    command.CommandText = sql
                    Using adapter As New ZohoDataAdapter(command)
                        adapter.Fill(table)
    
                        adapter.UpdateCommand = New ZohoCommand("UPDATE Accounts SET ""Account Name"" = @name WHERE AccountID = @id", connection)
    
                        adapter.UpdateCommand.Parameters.Add("id", DbType.String).SourceColumn = "AccountID"
                        adapter.UpdateCommand.Parameters("id").SourceVersion = DataRowVersion.Original
                        adapter.UpdateCommand.Parameters.Add("name", DbType.String).SourceColumn = "Account Name"
    
                        Dim firstrow As DataRow = table.Rows(0)
                        firstrow("Account Name") = "sample name 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 CRM data using ZohoCommand.

    using Devart.Data.Zoho;
    ...
    class Program
    {
    
        static void Main(string[] args) {
    
            const string connectionString = "security token=d3c6452922f65c24b59c75aee0d0112b;";
            const string sql = "UPDATE Accounts SET Website = 'www.devart.com' WHERE \"Account Name\" = 'sample name 1'";
    
            using (ZohoConnection connection = new ZohoConnection(connectionString)) {
    
                connection.Open();
                using (ZohoCommand command = connection.CreateCommand()) {
    
                    command.CommandText = sql;
                    Console.WriteLine(command.ExecuteNonQuery());
                }
            }
            Console.ReadKey();
        }
    }
    
    
    Imports Devart.Data.Zoho
    ...
    Module Module1
    
        Sub Main()
    
            Const connectionString As String = "security token=d3c6452922f65c24b59c75aee0d0112b;"
            Const sql As String = "UPDATE Accounts SET Website = 'www.devart.com' WHERE ""Account Name"" = 'sample name 1'"
    
            Using connection As New ZohoConnection(connectionString)
    
                connection.Open()
                Using command As ZohoCommand = 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