Results 1 to 2 of 2

Thread: ini-xml

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    ini-xml

    Currently I am usiing an ini file with vb 6 to get the names of the server, database, username, password.
    I wouold like to do the same thing in .net
    What is the best way to do this? Should I use the ini file as it is now or is it best to call an xml file which has the same info as the ini file.
    Thanks

  2. #2
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551
    Umm, you've posted in the ASP.NET forum, so i'm assuming you want to do this with an asp.net application... If so, i think you should take a look at the web.config file... you can add your own configuration settings that are accessible by all pages in that web...

    for example:

    VB Code:
    1. ?xml version="1.0" encoding="utf-8" ?>
    2. <configuration>
    3.    
    4.   <system.web>
    5.  
    6.      'Some other configuration information is here
    7.    
    8.   </system.web>
    9.   <appSettings>
    10.     <add key="conString" value="Server=myserver.com;UID=MyUsername;PWD=MyPassword;Database=MyDatabase" />
    11.     <add key="WebPath" value="C:\InetPub\wwwroot\MyWeb\" />
    12.   </appSettings>
    13.  
    14. </configuration>

    then you can retrieve these settings with the following code:
    VB Code:
    1. ConfigurationSettings.AppSettings("conString")

    Quite simple i think... this might not be an extremely secure method to store things like database passwords, but it would be just as secure, if not more secure than an ini or xml file in the same directory...

    I'm pretty sure that you can add and/or edit settings programmatically as well, however i've never had the need to do so, so i can't provide any code examples for that..

    If you're looking for something similar for a VB.NET app, well, i think you can do something much the same except it would be with the MyExeName.config file.. but don't quote me on this, i haven't worked enough with vb.net to know for sure...

    anyways, that should get you started

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width