在C#.net Windows窗体应用程序中打开连接的位置我是C#.net的新手 [英] where to open connection in c# .net windows form application I am new to c# .net

查看:43
本文介绍了在C#.net Windows窗体应用程序中打开连接的位置我是C#.net的新手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手

是否可以像vb这样的c#在模块中一次打开连接并在Windows窗体应用程序中使用整个应用程序.

在C#Windows Form应用程序中的何处打开连接.

请帮帮我.

在此先感谢.

I am new to c#

Is it possible in c# like vb to open connection one time in module and use through out application in windows form application.

Where to open connection in c# windows form application.

Please help me.

Thanks in Advance.

推荐答案

是的,有可能.与VB模块最接近的等效项是C#2.0中的静态类(或带有2.0之前的静态成员的密封C#类).
Yes it is possible. The closest equivalent to a VB module is a static class in C# 2.0 (or a sealed C# class with static members prior to 2.0).


就像在VB中一样,您可以放置​​Connection.在数据访问层的全局类中某个地方打开字符串.
如果只希望该类的一个实例存在,则可以使该类为单例.
Just like in VB, you can place the Connection.Open string somewhere in a global class in the data access layer.
You can make this class a singleton, if you want only one instance of this class to exist.


希望 ^ ]和 Link2 [
Hope link1[^] and Link2[^]might help you.


这篇关于在C#.net Windows窗体应用程序中打开连接的位置我是C#.net的新手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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