C winforms sql search to datagridview
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill c-winforms-sql-search-to-datagridviewAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Generates C# code to perform a parameterized SQL search and display results in a DataGridView, including input validation and specific connection handling.
SKILL.md
2.0 KB, as published. Nobody here has run it
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
- Data Retrieval: Use
SqlDataAdapterandDataSetto retrieve data. Bind the results to the DataGridView usingDataSource = ds.Tables[0]. - Query Construction: Use parameterized queries (e.g.,
@ParamName) within theSqlCommandto prevent SQL injection. Do not use string concatenation for values. - Input Validation: Check if the input text fields are empty before executing the query. If empty, show a
MessageBoxindicating missing entries. - Connection Management: Explicitly open the connection (
Con.Open()) before execution and close it (Con.Close()) after. - Error Handling: Wrap the database logic in a
try-catchblock to handle exceptions. - User Feedback: Display a success message (e.g.,
MessageBox.Show("Search Done")) after the data is bound.
Anti-Patterns
- Do not use
SqlDataReaderfor this task unless explicitly requested; prefer theSqlDataAdapterpattern 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