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);
                }
            }


     

  • 相关阅读:
    mysql性能分析工具
    vim使用大全
    Vue computed属性
    模板题 + KMP + 求最小循环节 --- HDU 3746 Cyclic Nacklace
    Greedy --- HNU 13320 Please, go first
    DFS --- HNU 13307 Galaxy collision
    HNU 13308 Help cupid
    Linux
    dp
    2015 Multi-University Training Contest 2 1006 Friends
  • 原文地址:https://www.cnblogs.com/scottckt/p/2755469.html
Copyright © 2011-2022 走看看