/// <summary> /// Example of an INSERT of a BLOB /// </summary> /// <param name="customerId">The customer ID.</param> /// <param name="itemId">the item ID.</param> /// <exception cref="AceQLException">If any Exception occurs.</exception> public async Task InsertBlobProgressIndicator(int customerId, int itemId) { // Create a transaction because some database engines require autocommit off AceQLTransaction transaction = await connection.BeginTransactionAsync(); try { string sql = "insert into orderlog values " + "(@customer_id, @item_id, @description, " + "@item_cost, @date_placed, @date_shipped, " + "@jpeg_image, @is_delivered, @quantity)"; AceQLCommand command = new AceQLCommand(sql, connection); string userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); string blobPath = userPath + "\\koala.jpg"; Stream stream = new FileStream(blobPath, FileMode.Open, FileAccess.Read); long length = new FileInfo(blobPath).Length; AceQLConsole.WriteLine("blobPath: " + blobPath); AceQLConsole.WriteLine("insert into orderlog..."); command.Parameters.AddWithValue("@customer_id", customerId); command.Parameters.AddWithValue("@item_id", itemId); command.Parameters.AddWithValue("@description", "Item Description"); command.Parameters.AddWithValue("@item_cost", 99D); command.Parameters.AddWithValue("@date_placed", DateTime.Now); command.Parameters.AddWithValue("@date_shipped", DateTime.Now); command.Parameters.AddWithValue("@jpeg_image", stream, length); command.Parameters.AddWithValue("@is_delivered", 1); command.Parameters.AddWithValue("@quantity", 1); AceQLProgressIndicator progressIndicator = new AceQLProgressIndicator(); connection.SetProgressIndicator(progressIndicator); await command.ExecuteNonQueryAsync(); await transaction.CommitAsync(); } catch (Exception e) { // Transaction must always be terminated by a CommitAsync() or RollbackAsync() await transaction.RollbackAsync(); throw e; } }