开发者

Global Connection from SQL Server Database to VB.NET

开发者 https://www.devze.com 2023-03-20 17:31 出处:网络
I want to create a global connection class from Sql server database to vb.net to make it easy in later editing the connection. Could anyone guide me the way to开发者_JAVA百科 code both creating and ca

I want to create a global connection class from Sql server database to vb.net to make it easy in later editing the connection. Could anyone guide me the way to开发者_JAVA百科 code both creating and calling to individual form?

Any help would be appreciated. Thanks


Keep your connection string in your web.config file. (this gives you a single point where you can change the connection string without needing to recompile your application, it also allows you to encrypt it in the future to protect your DB server).

I'd advise against using a single "connection" object for reuse. Open and close a connection for each query or transaction.

Check out the Repository pattern instead. http://msdn.microsoft.com/en-us/library/ff649690.aspx

0

精彩评论

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