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);
                }
            }
    
  • 相关阅读:
    verilog中的function用法与例子
    HDMI IP学习笔记
    include使用中注意的问题
    PCIE学习
    HDMI学习
    (转)modelsim10.0C编译ISE14.7的xilinx库(xilinx ip核)
    2014年七月华为校招机试题目--最难的一道, 呵呵!
    欧拉函数
    素数高效率筛选法
    树-二叉树的编号
  • 原文地址:https://www.cnblogs.com/haoliansheng/p/4772986.html
Copyright © 2011-2022 走看看