In This Topic
You can update the Zoho Books data either by modifying data returned by the ZohoBooksDataAdapter class and then calling its Update method or by performing corresponding DML statements (INSERT, DELETE, UPDATE) via ZohoBooksCommand.
Here is an example showing how to update Zoho Books data using ZohoBooksDataAdapter.
using Devart.Data.ZohoBooks;
...
class Program
{
static void Main(string[] args) {
const string connectionString = "security token=d3c6452922f65c24b59c75aee0d0112b;";
const string sql = "SELECT AccountID, \"Account Name\" FROM Accounts";
using (ZohoBooksConnection connection = new ZohoBooksConnection(connectionString)) {
connection.Open();
DataTable table = new DataTable("Accounts");
using (ZohoBooksCommand command = connection.CreateCommand()) {
command.CommandText = sql;
using (ZohoBooksDataAdapter adapter = new ZohoBooksDataAdapter(command)) {
adapter.Fill(table);
adapter.UpdateCommand = new ZohoBooksCommand("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.ZohoBooks
...
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 ZohoBooksConnection(connectionString)
connection.Open()
Dim table As New DataTable("Accounts")
Using command As ZohoBooksCommand = connection.CreateCommand()
command.CommandText = sql
Using adapter As New ZohoBooksDataAdapter(command)
adapter.Fill(table)
adapter.UpdateCommand = New ZohoBooksCommand("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 Books data using ZohoBooksCommand.
using Devart.Data.ZohoBooks;
...
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 (ZohoBooksConnection connection = new ZohoBooksConnection(connectionString)) {
connection.Open();
using (ZohoBooksCommand command = connection.CreateCommand()) {
command.CommandText = sql;
Console.WriteLine(command.ExecuteNonQuery());
}
}
Console.ReadKey();
}
}
Imports Devart.Data.ZohoBooks
...
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 ZohoBooksConnection(connectionString)
connection.Open()
Using command As ZohoBooksCommand = 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