# DataSourceRegistry.Remove Method

> DataSourceRegistry.Remove method in the TX Sheet Control .NET API: Removes a query and its cache; subsequent requests fail.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Namespace:** `TXTextControl.TXSheetControl.Data`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Data.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Data > DataSourceRegistry > DataSourceRegistry.Remove Method
- **1312 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/remove-method/llms-full.txt

---

Removes a query and its cache; subsequent requests fail. Already-running requests can finish.

### Syntax

```csharp
public bool Remove(string connectionId, string queryId)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `connectionId` | `string` | No | Value matching connectionId's declared type and the owning object's validation rules. |
| `queryId` | `string` | No | Value matching queryId's declared type and the owning object's validation rules. |

### Return Value

`bool`.

### Examples

Create a working report from bounded HTTP sales data. Supply an application-owned HttpClient and service URL; scope cached data to its actual audience.

```csharp
using System.Net.Http;
using TXTextControl.TXSheetControl.Data;
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> BuildDataSourceRegistryRemoveAsync(ServerSheetControl control, HttpClient client, Uri serviceBase)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var source = new HttpDataSource(client, request => new HttpRequestMessage(HttpMethod.Get, new Uri(serviceBase, "sales?offset=" + request.Offset + "&limit=" + request.Limit)), ["Region", "Revenue"]);
    var registry = new DataSourceRegistry();
    registry.Register("sales-service", "regional-sales", source);

    var request = new DataRequest { Offset = 0, Limit = 100, Parameters = new Dictionary<string, object?> { ["year"] = 2026 } };
    var options = new DataQueryOptions { Timeout = TimeSpan.FromSeconds(15), CacheDuration = TimeSpan.FromMinutes(1), CacheScope = "public-regional-sales" };
    using var binding = new WorkbookDataBinding(book, registry);
    await binding.RefreshRangeAsync(sheet.Range("A1:B101"), "sales-service", "regional-sales", request, options);
    await sheet.Range("A1:B1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    // Retire this query after the one-time report; existing worksheet values remain.
    if (!registry.Remove("sales-service", "regional-sales"))
    {
        throw new InvalidOperationException("The registered query was unexpectedly absent.");
    }
    return await control.SaveAsync(StreamType.PDF);
}
```

### Remarks

Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.

### See Also

- [DataSourceRegistry Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/llms-full.txt)
- [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)

---

## Nearby

- **Previous:** [DataSourceRegistry.Register Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/register-method/llms-full.txt)
- **Next:** [HttpDataSource Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/llms-full.txt)
