-
October 28th, 2014, 10:59 PM
#1
SQL connection in the app.config file?
After the load is connected to the variable string "connectionString", Question of the standard functions of C # can be taken out each piece as: [Server = localhost] and [Port = 5432] and ... [CommandTimeout = 10], to give them form into log form as SQL Server Management Studio 2005 from here Modifying, update, add delete, ... and after the break will be saved to the app.config file
-
October 29th, 2014, 09:35 AM
#2
Re: SQL connection in the app.config file?
-
October 29th, 2014, 08:55 PM
#3
Re: SQL connection in the app.config file?
How to change connection string in app.config dynamicaly using c#.net2.0 ?
-
October 29th, 2014, 09:19 PM
#4
Re: SQL connection in the app.config file?
Use more than one instance of SQLExpress. SQLExpress1, SQLExpress2, etc.
-
October 30th, 2014, 03:57 AM
#5
Re: SQL connection in the app.config file?
i save connectstring warning error: The index being passed in is out of range
Code:
public void updateConfigFile(string con)
{
//updating config file
XmlDocument XmlDoc = new XmlDocument();
//Loading the Config file
XmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
foreach (XmlElement xElement in XmlDoc.DocumentElement)
{
if (xElement.Name == "connectionStrings")
{
//setting the connection string
xElement.FirstChild.Attributes[2].Value = con; // error here
}
}
//writing the connection string in config file
XmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
}
-
October 30th, 2014, 09:11 AM
#6
Re: SQL connection in the app.config file?
Originally Posted by dongtrien
i save connectstring warning error: The index being passed in is out of range
Code:
//setting the connection string
xElement.FirstChild.Attributes[2].Value = con; // error here
So why do you pass index 2 when 2 is out of range?
Victor Nijegorodov
-
October 30th, 2014, 08:47 PM
#7
Re: SQL connection in the app.config file?
because the connection string have got 2 the connection string
Also, when running the program does not understand why the folder bin\Debug\ always appear 2 files: Myprogram.exe.config (file containing an unencrypted connection string) and Myprogram.vshost.exe.config (containing the string encrypted connection), it normally only files appear Myprogram.exe.config why add another file? how can I turn down one file?
Last edited by dongtrien; October 30th, 2014 at 09:26 PM.
-
October 31st, 2014, 02:09 AM
#8
Re: SQL connection in the app.config file?
Originally Posted by dongtrien
because the connection string have got 2 the connection string
Even if there are two, the index cannot be 2: only 0 and 1.
Victor Nijegorodov
-
October 31st, 2014, 09:30 AM
#9
Re: SQL connection in the app.config file?
Originally Posted by dongtrien
because the connection string have got 2 the connection string
Also, when running the program does not understand why the folder bin\Debug\ always appear 2 files: Myprogram.exe.config (file containing an unencrypted connection string) and Myprogram.vshost.exe.config (containing the string encrypted connection), it normally only files appear Myprogram.exe.config why add another file? how can I turn down one file?
The xxx.vshost.exe.config gets created when you debug your program from inside the Visual Studio IDE. It won't get used (or created) when running outside Visual Studio.
-
November 4th, 2014, 09:52 PM
#10
Re: SQL connection in the app.config file?
encrypt the connection string in the app.config file ? While this example was run error: Unable to find manifest signing certificate in the certificate store? and error connection string in the app.config file. thanks to bands such property protection. you see link: http://www.ardabasoglu.com/blog/encr...ation-settings
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|