窗体应用程序运行时数据库连接 [英] Forms application Run-Time Database Connection

查看:95
本文介绍了窗体应用程序运行时数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力寻找一种简单的方法来处理Windows Forms应用程序中与sql数据库的动态(运行时)连接.我发现一些使用COM和Interop的答案似乎过时了.

这是要求:


  • 首次使用该应用程序时,用户将信息输入表单以直接连接到 THEIR 数据库.
  • 信息将被吸收为连接字符串并经过测试. /li>
  • 用户保存了该信息,以便在应用程序每次运行时都可以使用.
  • 用户可以根据自己想要使用的数据库添加更多连接并修改连接.
  • li>
  • 信息被保存在只能由程序访问的位置.
  • 信息被保存以确保用户名和密码安全.
  • I have been searching diligently for a straight-forward way to handle a dynamic (runtime) connection to a sql database in Windows Forms application. I have found some far-out answers using COM and Interop that just seem antiquated.

    Here is the requirement:


    • Upon first use of the Application, the user enters information into the form to connect directly to THEIR database.
    • The information is assimilated into a Connection String and Tested.
    • The user saves this information to be used everytime the Application runs.
    • The user has the ability to add more connections and modify the connections depending on the database they want to use.
    • The information is saved SOMEWHERE where it can only be accessed by the program.
    • The information is saved so the that the username and password are secure.
    • 推荐答案

      您说您一直在搜索,因此您可能已经看过 .NET Windows安全开发人员指南 [<已经是href ="http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook.HomePage" target ="_ blank" title ="New Window"> ^ ].

      如果没有,它有一些好主意,即使您看过它也有一些好主意:).
      You say you have been searching, so you may have seen The .NET Developer''s Guide to Windows Security[^] already.

      If not, it has some good ideas, well it has some good ideas even if you have seen it :) .


      错. app.config文件不会被包裹在任何东西中.它与您创建的.EXE位于同一目录中,与.EXE具有相同的名称,只是附加了.config.例如,如果您的应用程序编译为MyApp.exe,则配置文件将为MyApp.exe.config.

      就像其他文件一样,它是一个普通的XML文件.您可以随时对其进行编辑.
      Wrong. The app.config file doesnt'' get wrapped in anything. It sits in the same directory as the .EXE your made, with the same name as the .EXE, just with .config appended to it. For example, if your app compiles to MyApp.exe, the config file would be MyApp.exe.config.

      It''s a normal XML file, just like any other. You can edit it any time you want.


      这篇关于窗体应用程序运行时数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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