vb.NET 2008:如何通过多种形式使用数据库连接
我目前正在 vb.NET 2008 中测试数据库编程,并尝试找到一种以不同形式使用数据库连接的方法,因此,例如,我将数据库连接组件放入其中一个形式中。
我知道,我可以通过例如 form1.databaseconnection.xxx 访问它,但这是最好的方法还是我可以将连接“放入”所有表单都知道的更抽象的东西中?
谢谢
I'm testing database programming in vb.NET 2008 at the moment and try to find a way to use a database connection in different forms, so e.g. I put the the database-connection-component into one of the forms.
I know, I could access it by e.g. form1.databaseconnection.xxx, but is this the best way or can I "put" the connection into something more abstract which all forms know about?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在单独的类库项目上实现数据访问层并在 Windows 应用程序项目上添加对它的引用,那就更好了。
Better if you implement a Data Access Layer on a separate Class Libraray project and add a reference to it on you windows application project.
我必须做出一个非常相似的设计决策,并且我决定最好共享一个主要对象的连接,并通过调用重载的 Show() 方法将其传递给 Forms。
MyController 是一个包含几个重要内容的类,例如 DB-Connection 等。
I had to take a pretty similar design decision, and I decided that it would be the best to share the connection from one major object, and hand it to Forms by calling an overloaded Show()-Method.
MyController is a class which holds several important things, like the DB-Connection etc. .