开发者

MySQL and C#.NET DataGridView, Updates, Inserts and Deletes

The other day I started working on a project in C#.NET using Windows Forms and it's been quite a while since I last used Windows Forms so I'm feeling a bit rusty.

First off I should point out that I'm using Visual C# 2010 Express which does not have GUI wizard support for databindings (well it does, if you enjoy MS Access or locally stored database files) and I need to speak to a MySQL database and make it play nice with a DataGridView.

My problem stems from the fact that I can't quite figure out how to do updates and deletes. Most online sources I've found seem to just refer to running the data binding wizard, something I can't do (开发者_JAVA百科since I'm running Visual C# 2010 Express).

Now, I've been able to select data from the database without any major problems (using a MySqlDataAdapter, a BindingSource and a DataTable) but when I try to use MySqlDataAdapter.Update(<DataTable>) nothing happens.

I'm assuming there is some setup work I need to do which is normally handwaved away as "just use the wizard". So, does anyone have a simple example of what I need to do to be able to do updates, inserts and deletes? With or without stored procedures, both ways are fine (although I'll probably end up used stored procs in the finished program).


I suggest you to do not use those DragDroppable DataAdapter or BindingSources from the VS Toolbox, just layer your project properly in different projects each one with its own concern, like Data Access, Business Logic and Presentation (GUI).

see my answer here: MVC3 and Entity Framework

if you have a solid layered / m-tier architecture you will find out that data management logic belongs only to the Data Access Layer and the UI just has to ask what is needed going through the Business Logic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜