使用Windows窗体数据库如何执行基本的CRUD? [英] How do you perform basic CRUD on a database using windows forms?

查看:146
本文介绍了使用Windows窗体数据库如何执行基本的CRUD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用.net框架广泛用于后端进程和网页,但我从来没有需要使用Windows窗体。唯一的经验,我有Windows窗体类型的技术与德尔福6安培; 7

I have used the .Net framework extensively for backend processes and web pages but I have never needed to use Windows Forms. The only experience I have with Windows form type technology is with Delphi 6&7.

我已经寻找教程,因为他们似乎是太简单了,我在寻找什么。或者,它似乎不适合我想做的事情。

I have searched for tutorial as they seem to be too basic for what I am looking for. Or it seems inappropriate for what I am trying to do.

我想有一个窗体上的网格显示(为了这个,我一直在使用的DataGridView)(我已成功地做),以便用户可以查看,过滤和搜索数据。像分页其他的事情也将参与,但我认为我可以计算出如何做到这一点我自己。

I would like to have a grid display (for this I have been using DataGridView) on a form (which I have managed to do) so that the user can view, filter and search for data. Other things like pagination would also be involved but I think that I can work out how to do that for myself.

所有的余遇到使用在DataGridView进行编辑的例子中,添加和删除,以及。我不认为舒服的想法,用户用户网格的一切。这似乎令人困惑,并可能相当容易出错。

All of the examples I come across use the DataGridView for editing, adding and deleting as well. I am not that comfortable with the idea that user user the grid for everything. It seems confusing and likely to be quite error prone.

我想有按钮来添加,编辑和删除的各种类型的数据。因此,举例来说,如果我有一个管理客户的形式,我想是能够选择要编辑并单击按钮行。这应该与所有ploaded的文本框,单选按钮,复选框和下拉列表等数据$ P $打开一个新的窗口形式

I would like to have buttons to Add, Edit and Delete the various types of data. So for example if I had a Form to manage customers, I would like to be able to select the row to edit and click the button. This should open a new windows form with all the data preloaded in textboxes, radio buttons, checkboxes and dropdowns etc.

如果他们点击添加,他们会去同一个屏幕编辑以外的所有信息会有空白。如果他们选择一行并单击删除它将然后删除该客户,并从DataGridView中删除它。

If they click add they would go to the same screen as the edit except all the information there would be blank. If they select a row and clicked delete it would then delete that customer and remove it from the DataGridView.

对于一些我已经尝试过了,似乎获取所有从表中的行的控件和数据绑定选项。我怎么能只让我很感兴趣,从数据库的行。我不知道什么最佳实践在这里。

With some of the controls and databinding options I have tried it seems to fetch ALL the rows from the table. How would I be able to just get the row that I am interested in from the database. I am not sure what best practises are here.

我是从信息过载的痛苦,现在,只想AP preciate有人指出了正确的方向。

I am suffering from information overload right now and would just appreciate someone point me in the right direction.

编辑:

我要指出,从我的德尔福天,我期待能够建立类似的查询或SqlCommand时(拖放的GUI),并设置它的SQL属性,也许是参数化的SQL一点点。拖放一个数据源的形式。点数据源的使用SqlQuery / SqlCommand的,点击激活命令。现在,我可以拖放compononents到窗体并设置其数据源属性和田野,他们参考一下。

I should mention that from my Delphi days I am expecting to be able to set up something like a query or SqlCommand (Drag and drop on the gui) and set its SQL property, perhaps parameterize the SQL a little bit. Drag and drop a datasource on the form. Point the datasource to the SqlQuery/SqlCommand and click activate on the command. Now I can drag and drop compononents onto the form and set their datasource properties and to the field that they refer to.

推荐答案

看看这个样本。它显示了基本的ADO.NET结合的WinForm对照(不只是在DataGridView)。

Take a look at this sample. It shows basic ADO.NET binding to WinForm controls (not just the DataGridView).

这篇关于使用Windows窗体数据库如何执行基本的CRUD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆