类库中的ConnectionString [英] ConnectionString in Class Library

查看:122
本文介绍了类库中的ConnectionString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在开发一个Web应用程序,并且正在使用它的类库,我面临的问题是我如何将aspx.cs的连接传递给类库类,我正在使用某些技术,但认为这没有更好的选择,这些技术是:

我正在给每个类构造函数传递连接字符串,并为任何查询打开和关闭它,但是我认为这种方法不好,请问有人可以帮助我,我真的很感谢你们.


问候

Hi

I am developing a web application and i am using a class library with it, the problem i am facing is that how can i pass connection from my aspx.cs to class library classes, some techniques i am using but dont think that are better, that techniques are:

i am giving passing connection string to each class constructor and opening and closing it for any query, but i think this approach is not good, can any one please help me in this matter, i m really thankful to you people.


Regards

推荐答案


  • 您应该在Web项目的web.config文件中具有ConnectionString.
  • 您从Web项目引用的类库应从Web.config文件中读取.

  • You should have the ConnectionString in your web.config file of your web project.
  • Class library you are referencing from the Web project should read from the Web.config file.


这篇关于类库中的ConnectionString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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