如何在代码中使用在Visual Studio中创建的数据连接?
是否可以在代码中访问添加到项目中的数据连接?
我知道可以访问使用可视化设计器创建的数据集,但我只想访问连接。
编辑:
可以通过“工具”>“VS2008”将数据连接添加到项目中连接到数据库。
我想在代码中作为对象访问此连接,这样我就不必自己指定连接字符串。
Is it possible to access the Data Connection added to the project in the code?
I know that it is possible to access DataSets created using visual designer but I would like to access the connection only.
Edit:
It is possible to add Data Connection to the project in VS2008 via Tools > Connect to Database.
I would like to access this connection as an object in my code so that I would not have to specify connection string by myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不能直接使用 IDE 创建的连接,就像它是您的项目设置之一一样。但是,IDE 通过项目属性提供类似的功能。
根据您使用的语言/默认配置,获取属性的方式略有不同。但一般来说,您应该能够尝试这些步骤,看看它们是否提供您想要的功能:
现在您应该能够从项目代码访问此连接字符串。
VB.Net:C#
:
I don't think you can directly use the connection created by the IDE as if it were one of your project's settings. However, the IDE provides similar functionality through the project properties.
How you get to the properties varies slightly on which language/default configuration you are using. But in general you should be able to try these steps and see if they provide the functionality you wanted:
Now you should be able to access this connection string from your project code.
VB.Net:
C#: