zoukankan      html  css  js  c++  java
  • 通用数据链接(UDL)的用法

    偶然看到UDL,决定看一下其用法。

    UDL:通用数据链接。此文件中提供 OleDbConnection 的连接信息。也就是说UDL只能在OleDbConnection中使用。

    微软不建议使用UDL

        因为UDL 文件未加密,会以明文形式公开连接字符串信息。因为 UDL 文件对您的应用程序来说是一个基于文件的外部资源,所以无法使用 .NET Framework 保护该文件。

    用法:   

        在桌面上建一个名为conn的txt文本文件,然后将后缀名改为udl 。双击它,打开相应连接界面,根据界面提示配置连接信息。这里选择的是Oralce。

        配置成功后UDL内容为:

    [oledb] ; Everything after this line is an OLE DB initstring Provider=OraOLEDB.Oracle.1;Password=gsc;Persist Security Info=True;User ID=gsc;Data Source=NDEV

    代码中使用此UDL时,ConnectionString 需要为“File Name =”+UDL地址。

    private void GetData()
            {
                using (OleDbConnection oleconn = new OleDbConnection())
                {
                    oleconn.ConnectionString = @"File Name =" + Server.MapPath("conn.udl");
                    OleDbCommand olecommand = new OleDbCommand();
                    olecommand.Connection = oleconn;
                    olecommand.CommandText = "select * from CUSTOMIZATION";
                    oleconn.Open();
                    OleDbDataAdapter oleadapter = new OleDbDataAdapter();
                    oleadapter.SelectCommand = olecommand;
                    DataSet ds = new DataSet();
                    oleadapter.Fill(ds);
                }
            }
    
  • 相关阅读:
    有点难度的二分
    请教神牛_字符串hash
    引水进城
    dp的斜率优化
    关于学习oi的一些事项
    永续债
    消费税
    增值税
    BSC交流
    钉钉吐槽功能点
  • 原文地址:https://www.cnblogs.com/haoliansheng/p/4772986.html
Copyright © 2011-2022 走看看