Click here to Skip to main content
15,913,239 members
Home / Discussions / C#
   

C#

 
QuestionConnecting to database Pin
kibromg9-Feb-09 5:54
kibromg9-Feb-09 5:54 
AnswerRe: Connecting to database Pin
Rob Philpott9-Feb-09 6:03
Rob Philpott9-Feb-09 6:03 
GeneralRe: Connecting to database [modified] Pin
kibromg9-Feb-09 6:16
kibromg9-Feb-09 6:16 
GeneralRe: Connecting to database Pin
Rob Philpott9-Feb-09 6:27
Rob Philpott9-Feb-09 6:27 
GeneralRe: Connecting to database Pin
kibromg9-Feb-09 6:33
kibromg9-Feb-09 6:33 
GeneralRe: Connecting to database Pin
Rob Philpott9-Feb-09 6:43
Rob Philpott9-Feb-09 6:43 
GeneralRe: Connecting to database Pin
kibromg9-Feb-09 6:57
kibromg9-Feb-09 6:57 
GeneralRe: Connecting to database Pin
Rob Philpott9-Feb-09 8:54
Rob Philpott9-Feb-09 8:54 
The class below should do what you want, create a new instance passing in the config file as the parameter to the constructor.

public class DatabaseConfiguration
{
    public readonly string SqlServer;
    public readonly string Database;
    public readonly string User;
    public readonly string Password;
    public readonly bool Trusted;

    public DatabaseConfiguration(string path)
    {
        XmlDocument settings = new XmlDocument();
        settings.Load(path);

        SqlServer = settings.SelectSingleNode("/configuration/sqlserver").InnerText;
        Database = settings.SelectSingleNode("/configuration/sqldatabase").InnerText;
        User = settings.SelectSingleNode("/configuration/sqluser").InnerText;
        Password = settings.SelectSingleNode("/configuration/sqlpassword").InnerText;
        Trusted = settings.SelectSingleNode("/configuration/sqltrusted").InnerText.ToLower() == "true";
    }
}


Regards,
Rob Philpott.

GeneralRe: Connecting to database Pin
kibromg9-Feb-09 23:41
kibromg9-Feb-09 23:41 
GeneralRe: Connecting to database Pin
Rob Philpott9-Feb-09 23:50
Rob Philpott9-Feb-09 23:50 
GeneralRe: Connecting to database Pin
kibromg10-Feb-09 0:05
kibromg10-Feb-09 0:05 
GeneralRe: Connecting to database Pin
Rob Philpott10-Feb-09 0:19
Rob Philpott10-Feb-09 0:19 
GeneralRe: Connecting to database Pin
kibromg10-Feb-09 0:37
kibromg10-Feb-09 0:37 
GeneralRe: Connecting to database Pin
Rob Philpott10-Feb-09 0:57
Rob Philpott10-Feb-09 0:57 
GeneralRe: Connecting to database Pin
kibromg10-Feb-09 1:09
kibromg10-Feb-09 1:09 
QuestionExtract data in a binary file using c# Pin
mamamiya_9-Feb-09 5:18
mamamiya_9-Feb-09 5:18 
AnswerRe: Extract data in a binary file using c# Pin
led mike9-Feb-09 5:32
led mike9-Feb-09 5:32 
AnswerRe: Extract data in a binary file using c# Pin
#realJSOP9-Feb-09 5:56
professional#realJSOP9-Feb-09 5:56 
GeneralRe: Extract data in a binary file using c# Pin
mamamiya_9-Feb-09 6:21
mamamiya_9-Feb-09 6:21 
Question[Message Deleted] Pin
suni_dotnet9-Feb-09 5:07
suni_dotnet9-Feb-09 5:07 
QuestionRe: my senerio Pin
led mike9-Feb-09 5:11
led mike9-Feb-09 5:11 
AnswerRe: my senerio Pin
Dan Neely9-Feb-09 5:39
Dan Neely9-Feb-09 5:39 
QuestionFileSystemWatcher Pin
Jacob D Dixon9-Feb-09 5:03
Jacob D Dixon9-Feb-09 5:03 
AnswerRe: FileSystemWatcher Pin
led mike9-Feb-09 5:10
led mike9-Feb-09 5:10 
GeneralRe: FileSystemWatcher Pin
Jacob D Dixon9-Feb-09 5:18
Jacob D Dixon9-Feb-09 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.