'Want to make search function using SQL but never used databases
I made a Winforms application that displays rows of data in a DataGridView. I want to add a function that searches for specific rows based on text that the user enters in a Textbox. I have found examples that use SQL queries but I did not construct my DataGridView from an SQL database data source, I filled in each row manually one-by-one with strings and ints. https://www.c-sharpcorner.com/UploadFile/1e050f/search-record-in-datagridview-C-Sharp/
I am new to databases and I have a conceptual question. Can I create a temporary database at runtime without needing to install a password-protected database onto my system? This program is one that I share with colleagues as an .exe file and I don't want them to need to download and install an SQL database with a specific username/password just to run the program. I don't want the data stored in the database to persist when the program exits. I just want to be able to create a database and query it so I can implement a good search function for my DataGridView while the program is actually running. My program generates a completely new DataGridView at runtime based on the .txt log file that the user provides and has no need for data to persist between runs.
Solution 1:[1]
You don't need a Database behind your program to filter your DataGridView.
Instead of generating the DataGrid directly:
- retrieve and save your data in a separate list
- Filter the list using Linq and save the filtered result in a query
- apply the query result to your DataGridView DataSource
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mahmoud-Zino |
