Visual Basic 2010和SQL Server 2008帮助 [英] Visual Basic 2010 & SQL Server 2008 Help

查看:99
本文介绍了Visual Basic 2010和SQL Server 2008帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从大约4到5年前学习以来,我一直没有使用过它,所以我正在VB.NET端项目上工作,以刷新我对语言的记忆.

该项目是一个棒球计分卡,可用于创建团队,向团队中添加玩家,创建新游戏(团队之间的对决),对游戏进行评分以及跟踪统计信息.我有一个SQL Server数据库,其中包含要在VB 2010表单中读取和写入的所有内容的表.

我想要一个下一个"和上一个"按钮来使用文本框查看现有记录,一个新建"按钮可以在同一表格上创建空白记录,还有一个保存"按钮可以将对现有或新记录的更改归档.

我从学校读的书无济于事,因为自从我学到这些东西以来,似乎有些变化.我已经尝试了好几个小时,才能在网上找到不错的参考资料.我想要一个简单的教程,其中包含有关如何执行此操作的示例.谁能帮我吗?

I''m working on a VB.NET side project to refresh my memory of the language since I haven''t used it since I learned it about 4 or 5 years ago.

The project is a baseball scorecard that can be used to create teams, add players to teams, create a new game (matchup between teams), score the game, and track stats. I have a SQL Server database with tables for each of those things that I want to read from and write to in VB 2010 forms.

I''d like to have a Next and Previous button to view existing records using text boxes, a New button to create a blank record on the same form, and a Save button to file changes to an existing or new record.

My books from school aren''t helping because it seems a bit has changed since I learned this stuff. I''ve been trying for hours to find decent reference material online. I would like a simple tutorial with examples of how to do this. Can anyone help me out? Please?

推荐答案

很大的问题!我首先要考虑的几件事:
-是多用户环境吗?
-如果是,则数据是否需要最新
-数据编辑(或添加)中的冲突如何处理

因此,基本上所有这些问题都与您将来的应用程序中的数据行为有关.

基于这些问题,您可以决定是否可以使用DataTable对象存储数据,以浏览和修改数据并将修改传播到数据库.对于这种方法,请看一下:
- DataTable [ SqlDataAdapter [使用Windows窗体和ADO.NET进行数据绑定 [详细的数据绑定教程 [ SqlCommands [ ^ ].

如果不想直接使用数据库,可以做得更进一步,可以使用实体框架 [ ^ ].当然,这带来了一些新知识,因此可能需要花费更长的时间,但是从OOP角度来看,数据模型可能更易于使用.作为EF的补充,您还应该了解 LINQ到实体 [ ^ ].

然后,还有其他选择,例如是否使用开放式锁定,数据库操作,过程或程序中的操作等等.
Quite large question! Few things I would consider first:
- is it a multi-user environment
- if it is, does the data need to be up-to-date
- what about collisions in data editing (or adding) how they are handled

So basically all these questions are about the data behaviour in your future application.

Based on those questions, you can decide if you can use for example DataTable objects to store the data in order to browse and modify it and propagate the modifications to the database. For this approach, have a look atr:
- DataTable[^]
- SqlDataAdapter[^]
- Data Binding with Windows Forms and ADO.NET[^] (if this is forms)
- And and example: A Detailed Data Binding Tutorial[^]

If the data needs to be up-to-date all the time for all the users, you can of course use all of the above, but you need at least refresh the data more often and so on. Often this leads to a situation where you work more with SqlCommands[^].

To take things a bit further if you don''t want to work with the database directly, you could utilize Entity Framework[^]. Of course this brings some new things to learn so it may take a bit longer time but then again from OOP point of view the data model may be easier to use. As a side-dish to EF you should also get to know LINQ to Entities[^].

Then there would also be choices like whether to use optimistic locking or not, what about database operations, in procedures or in programs and so on.


我建​​议您看一下Visual Basic 2010&. NET 4高级编程,希望对您有所帮助.
I recommend to you see Visual Basic 2010 &.NET 4 Advanced Programming,hope to help you.


这篇关于Visual Basic 2010和SQL Server 2008帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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