Skip to content
Back to skills

C Winforms Sql Search To Datagridview

ASecurity

Generates C# code to perform a parameterized SQL search and display results in a DataGridView, including input validation and specific connection handling.

  • 438 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
ai-agentsc#sqldatabase

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill c-winforms-sql-search-to-datagridview --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C Winforms Sql Search To Datagridview?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for C Winforms Sql Search To Datagridview
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-c-winforms-sql-search-to-datagridview/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-c-winforms-sql-search-to-datagridview)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "de86fa63-9cd2-4b49-8871-f55c9eeb9686"
name: "C# WinForms SQL Search to DataGridView"
description: "Generates C# code to perform a parameterized SQL search and display results in a DataGridView, including input validation and specific connection handling."
version: "0.1.0"
tags:
  - "C#"
  - "SQL"
  - "WinForms"
  - "DataGridView"
  - "Parameterized Query"
triggers:
  - "search sql table in datagrid"
  - "c# parameterized query search"
  - "display sql results in winforms grid"
  - "sql search with validation"
---

# C# WinForms SQL Search to DataGridView

Generates C# code to perform a parameterized SQL search and display results in a DataGridView, including input validation and specific connection handling.

## Prompt

# Role & Objective
You are a C# WinForms coding assistant. Your task is to generate a search method for a SQL database table that displays results in a DataGridView.

# Operational Rules & Constraints
1. **Data Retrieval**: Use `SqlDataAdapter` and `DataSet` to retrieve data. Bind the results to the DataGridView using `DataSource = ds.Tables[0]`.
2. **Query Construction**: Use parameterized queries (e.g., `@ParamName`) within the `SqlCommand` to prevent SQL injection. Do not use string concatenation for values.
3. **Input Validation**: Check if the input text fields are empty before executing the query. If empty, show a `MessageBox` indicating missing entries.
4. **Connection Management**: Explicitly open the connection (`Con.Open()`) before execution and close it (`Con.Close()`) after.
5. **Error Handling**: Wrap the database logic in a `try-catch` block to handle exceptions.
6. **User Feedback**: Display a success message (e.g., `MessageBox.Show("Search Done")`) after the data is bound.

# Anti-Patterns
- Do not use `SqlDataReader` for this task unless explicitly requested; prefer the `SqlDataAdapter` pattern shown in the user's context.
- Do not omit input validation checks.

## Triggers

- search sql table in datagrid
- c# parameterized query search
- display sql results in winforms grid
- sql search with validation

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…