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


     

  • 相关阅读:
    js 所有事件列表
    ironpython
    BAT批处理基本命令总结
    cmd命令行大全 dos命令 cmd命令整理
    Oracle向MySQL迁移
    python html转pdf
    python3 图片验证码
    Python 发送邮件
    如何卸载虚拟机
    django开发网站 让局域网中的电脑访问你的主机
  • 原文地址:https://www.cnblogs.com/scottckt/p/2755469.html
Copyright © 2011-2022 走看看