想要使用SQL制作搜索功能,但从未使用过数据库

发布于 2025-01-21 17:25:55 字数 478 浏览 1 评论 0原文

我制作了一个Winforms应用程序,该应用程序在DataGridView中显示了数据行。我想添加一个函数,该功能根据用户在文本框中输入的文本搜索特定行。我发现了使用SQL查询的示例,但是我没有从SQL数据库数据源构造我的DataGridView,我用字符串和INT手动填写每行。 < .com/uploadfile/1E050F/search-record-in-datagridview-c-sharp/

我是数据库的新手,我有一个概念上的问题。我可以在运行时创建一个临时数据库,而无需在系统上安装受密码保护的数据库吗?该程序是我作为.EXE文件与同事共享的程序,我不希望他们需要下载并安装带有特定用户名/密码的SQL数据库,以运行该程序。我不希望在程序退出时存储在数据库中的数据继续存在。我只想能够创建一个数据库并查询它,以便在程序实际运行时可以为我的DataGridView实现一个良好的搜索功能。我的程序基于用户提供的.txt日志文件在运行时生成全新的DataGridView,并且不需要数据在运行之间持续存在。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗷兮 2025-01-28 17:25:55

您不需要程序背后的数据库即可过滤DataGridView。

Instead of generating the DataGrid directly:

  1. retrieve and save your data in a separate list
  2. Filter the list using Linq and save the filtered result in a query
  3. apply the query result to your DataGridView DataSource

You don't need a Database behind your program to filter your DataGridView.

Instead of generating the DataGrid directly:

  1. retrieve and save your data in a separate list
  2. Filter the list using Linq and save the filtered result in a query
  3. apply the query result to your DataGridView DataSource
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文