|
I tried that but I can not seem to get the value to return properly... Here is what I do..
I go to the application project manager,
right click on project
Say properties
Go to the settings tab and put
Name: SQLConnectionString
Type: string
Scope: Application
Value: "Data Source=PA-DEVPLATFORM1\SQL2005;Initial Catalog=AppLoader;Persist Security Info=True;User ID=Mike;Password=zephyr"
This SQLConnection String I am wanting in a external XML file editable to the end user so I do not have to recompile the application for every sql server change.
Here is the code I am using to call it. It does not work.
SqlConnection conn = new SqlConnection(Properties.Settings.Default.SQLConnectionString);
I can not seem to get
ConfigurationSettings.AppSettings
to be identified as a valid command...
I got close by adding
public static NameValueCollection AppSettings { get; }
but the applications says it needs a set added to it.
PLEASE any help on this?
----------------------------------------------------------
So far I have figured out to get the setting I think I need to do this?
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["SQLConnectionString"].ToString());
But it still comes back saying the string is null... Why?
modified on Wednesday, June 24, 2009 1:54 AM
|
|
|
|
|
Got it....
string testanswer = PeerAssistLoader.Properties.Settings.Default.SQLConnectionString.ToString(); //["SQLConnectionString"].ToString();
MessageBox.Show(testanswer);
I had the value in the settings with quotes around the connection string. Since I was viewing that field as a string value. Now I know better...
modified on Wednesday, June 24, 2009 2:16 AM
|
|
|
|
|
JollyMansArt wrote: I am wanting in a external XML file editable to the end user
If you want it editable by the end user, I would create my own using XMLDocument - there is a big risk of the user damaging other application settings by mistake if he is encouraged to edit the app.config file directly.
See Here[^] for an example.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
As Navaneeth says above, you probably want to use an app.config file for storing your connection string.
There are two ways of storing the connection string in said file.
The first is quick, dirty and I don't like it, but I'll show you anyway...
The connection string can be stored within the "appSettings" section of your app.config file, as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MainDB" value="Data Source=127.0.0.1;Initial Catalog=MainDB;User ID=usr;Password=pwd"/>
</appSettings>
</configuration>
To then read this setting from within your c# app, you'd need to use the following code:
System.Configuration.AppSettingsReader reader = new System.Configuration.AppSettingsReader();
string connString = (string)reader.GetValue("MainDB", typeof(string));
The reason I don't like the above method, is because the app.config specification includes a section specifically for connection strings.
Below is an example of an app.config that uses this section:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="MainDB" providerName="System.Data.SqlClient" connectionString="Data Source=127.0.0.1;Initial Catalog=MainDB;User ID=usr;Password=pwd"/>
</connectionStrings>
</configuration>
To then read this section, you first need to add a reference to "System.Configuration " to your project.
Then, you can use the code below:
string s = System.Configuration.ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString;
Much nicer
|
|
|
|
|
|
Hi all,
I am trying to get the following input data using http post .
i have my asp.net Page reading the data as :
if (Request.QueryString["customer_fname"] != null)
fname = Request.QueryString["customer_fname"];
the value of fname is test.However,Its alwyas having a null string.
IS it not getting the http post for the above html?
Can any one advice Please?
Thank you in advance
modified on Tuesday, June 23, 2009 7:10 PM
|
|
|
|
|
Hidden field, use Request.Form instead:
string fname = "";
if (Request.Form["customer_fname"] != null)
{ fname = Request.Form["customer_fname"]; }
Response.Write("fname value: " + fname);
Regards,
Gary
|
|
|
|
|
can someone put a code snip here that i can use to determin if a adusers is disabled
|
|
|
|
|
|
i tried this method to see if i could figure out if the user was disabled but i get and error i just wanted to see if i would get a 0x1 if the user account is not disbled and a 0x2 if it was
public void Disable(string userDn)
{
try
{
DirectoryEntry user = new DirectoryEntry(userDn);
int val = (int)user.Properties["userAccountControl"].Value;
\\ get the error on the above line
user.Properties["userAccountControl"].Value = val | 0x2;
//ADS_UF_ACCOUNTDISABLE;
}
catch (System.DirectoryServices.DirectoryServicesCOMException E)
{
//DoSomethingWith --> E.Message.ToString();
}
}
|
|
|
|
|
This is what I use passing in the DirectoryEntry object as a paramater.
public static bool CheckAccountDisabled(DirectoryEntry de)
{
int ACCOUNTDISABLE = 0x0002;
int flags = (int)de.Properties["userAccountControl"].Value;
if (((flags & ACCOUNTDISABLE) == ACCOUNTDISABLE))
{
return true;
}
return false;
}
modified on Thursday, June 25, 2009 6:02 PM
|
|
|
|
|
I've just started getting this for every breakpoint within a specific assembly.
"The breakpoint will not be hit, no symbols have been loaded for this document" I'm using a debug build, so what happened?
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Delete everything in your debug folder and clean your solution and rebuild, happens to me occasionally. This usually fixes it.
|
|
|
|
|
Not this time.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
You deleted your .pdb files as well? Close VS, delete pdb and binaries, open, clean solution and build.
Should solve it. Has to do with timestamps of builds not being updated, IIRC that info was held it the pdb files, deleting them, reopening VS with a clean solution / build solved it.
Give it another whack.
|
|
|
|
|
Yes.
I deleted the following folders with the solution closed:
<all projects="">\bin\debug\
<all projects="">\bin\release\
<all projects="">\obj\
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Sorry, that's what did it for me if I remember correctly. I can't remember if I deleted the .suo and .ncb files as well, but that might damage your solution and I don't want to corrupt your data.
|
|
|
|
|
I would do a rebuild all and see what happens.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Assuming you meant rebuild solution that didn't work.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Assuming you deleted all the files, that must mean that you're sure the exe you're running, is being build every time ?
I'd love to know what the root cause is, it sounds quite bloggable. ( http://thingsihateaboutmicrosoft.blogspot.com/[^] )
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
As as I can be without having the vista task managers option to find the path to the processes executable. I managed to fix it which is half way to the root cause...
I had two copies of the project on my start page. My normal build path, and a second leading to an second copy pulled from source control in a different location on my drive (a coworker had an odd issue after I checked something in and I wanted to make sure I didn't leave the source control with a version dependent on a non controlled file). I was opening the former, and all its bin\obj files were being rebuilt after deletion, but the problem went away when I deleted the bin/obj files from the second. Dunno any more about how it apparently managed to cross link something from the two copies.
My laptop LCD's borked and won't be replaced until today or tomorrow, but after that I can play around with this a bit at home if you've got any ideas on how to determine what the RC is.
We're using clearcase on this program (with the VS plugin) so it possible it is rational at fault not MS.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Make sure your startup project is referencing the correct version of the assembly (the one represented by the project in Visual Studio, as opposed to a specific external file.) It's possible that one of your projects is loading an older version of the assembly from some other path.
|
|
|
|
|
It's good now, but I didn't see your post until after I fixed the problem (see my last reply to CG).
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Hi
GetValue method (registrykey.getvalue()) dose not support REG_NONE keys.
how I get these values from c#?
|
|
|
|
|
Hi,
the .NET Registry classes still don't cover it all, one occasionally needs the original Win32 API functions, and P/Invoke to get to them. However I never needed any REG_NONE, are you sure you do, and it is worth it?
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|