如何在C#中创建一个SqlConnection指向UDL文件 [英] How to create an SqlConnection in C# to point to UDL file

查看:34
本文介绍了如何在C#中创建一个SqlConnection指向UDL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一个 .udl(通用数据链接)文件.现在我想创建一个指向这个特定文件的 SQL 连接.SqlConnection 对象需要一个连接字符串,我们如何使用 .UDL 文件构建一个 SqlConnection?

I have a .udl (Universal data link) file in my project. Now I want to create an SQL Connection that should point to this particular file. SqlConnection object expects a connection string, how can we build an SqlConnection using .UDL file?

推荐答案

来自 MSDN 站点:

From MSDN site:

可以为 OleDbConnection 提供连接信息在通用数据链接 (UDL) 文件中;但是你应该避免这样做所以.UDL 文件未加密,并公开连接字符串明文形式的信息.因为 UDL 文件是外部的应用程序的基于文件的资源,它不能使用.NET 框架.SqlClient 不支持 UDL 文件.

It is possible to supply connection information for an OleDbConnection in a Universal Data Link (UDL) file; however you should avoid doing so. UDL files are not encrypted, and expose connection string information in clear text. Because a UDL file is an external file-based resource to your application, it cannot be secured using the .NET Framework. UDL files are not supported for SqlClient.

看看这里:

http://social.msdn.microsoft.com/Forums/en-US/sqlnetfx/thread/0bb40f32-86f4-4b6f-a2e0-bc2bdcf07b63

这篇关于如何在C#中创建一个SqlConnection指向UDL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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