This C# Windows Forms application demonstrates a client interface for searching and viewing data from SQL and legacy database sources stored in a SQL Server database.
- Search across multiple data sources with unified interface
- Advanced filtering by date range and source
- Detailed record view with metadata exploration
- JSON export capabilities
- Data source statistics visualization
- Windows operating system
- .NET 6.0 SDK or newer
- SQL Server (Local, Express, or higher)
- Visual Studio 2022 or Visual Studio Code
# Create a new directory for the project
mkdir TestClientApp
cd TestClientApp
# Initialize Git repository (optional)
git init- Open Visual Studio
- Select "Create a new project"
- Choose "Windows Forms App (.NET)"
- Name it "TestClientApp"
- Create the solution
- Add the required NuGet packages:
- System.Data.SqlClient
- Newtonsoft.Json
- Dapper
- Microsoft.Extensions.Configuration
- Microsoft.Extensions.Configuration.Json
- Microsoft.Extensions.DependencyInjection
# Create solution
dotnet new sln -n TestClientApp
# Create Windows Forms project
dotnet new winforms -n TestClientApp -o TestClientApp
# Add project to solution
dotnet sln TestClientApp.sln add TestClientApp/TestClientApp.csproj
# Add required packages
cd TestClientApp
dotnet add package System.Data.SqlClient
dotnet add package Newtonsoft.Json
dotnet add package Dapper
dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.Json
dotnet add package Microsoft.Extensions.DependencyInjection
cd ..Create the following directory structure:
TestClientApp/
├── Models/
├── Services/
│ ├── Data/
│ └── Auth/
├── Utils/
├── Resources/
└── SQL/
-
Copy the C# class files for:
- Models (
SearchResult.cs,SearchCriteria.cs,UserPreference.cs,DataSource.cs) - Services (
IDataService.cs,SqlDataService.cs) - Forms (
MainForm.cs,DetailForm.cs) - Program entry point (
Program.cs)
- Models (
-
Create the
appsettings.jsonfile in the project root directory with the following content:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER_NAME;Database=TestDataSearch;Trusted_Connection=True;"
},
"AppSettings": {
"MaxSearchResults": 500,
"DefaultSearchResultsCount": 50,
"CacheTimeoutMinutes": 15
}
}- Open SQL Server Management Studio (SSMS)
- Connect to your SQL Server instance
- Execute the SQL script located in
SQL/01_CreateDatabase.sql
- Open the solution file (
TestClientApp.sln) in Visual Studio - Build the solution (F6 or Build > Build Solution)
- Run the application (F5 or Debug > Start Debugging)
# Build the project
dotnet build
# Run the application
dotnet run --project TestClientApp/TestClientApp.csprojIf you encounter database connection errors:
- Verify your SQL Server instance is running
- Check that the connection string in
appsettings.jsonis correctly configured - Ensure the TestDataSearch database has been created
- Verify Windows Authentication is working (if using Trusted_Connection)
For build errors:
- Restore NuGet packages:
dotnet restore - Check project references
- Verify all required files are in the correct directories
- Ensure .NET SDK version is compatible (6.0 or higher)
This application provides a foundation that can be extended with:
- Authentication/authorization features
- Advanced search filters
- Report generation
- Export to various formats (CSV, Excel)
- Integration with additional data sources
- Dashboard features