Click here to Skip to main content
11,705,473 members (55,051 online)
Rate this: bad
Please Sign up or sign in to vote.
im developing a winform and i store my connection in App.config
<add key="CS" value="Server=localhost;User ID=root;Password=123456;Persist Security Info=True;Database=dbMember"/>

and this is how i call the connectionString from C#
string CS = System.Configuration.ConfigurationManager.AppSettings.Get("CS");

yes, it can run smoothly at my machine, how it show error msg: "the connection property has not been set or is null", when i try to run it at another PC.

but it working at another PC if i manually code the connectionstring like this:
string CS= "Server=localhost;User ID=root;Password=123456;Persist Security Info=True;Database=dbMember";

any advice? i already install the same version of sql at both PC
Posted 22-Jan-13 21:33pm
Amol_B at 23-Jan-13 4:48am
"the connection property has not been set or is null" is indication of non initialization of connection. You are reading string from config file, but are you using it in connection?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You shouldn't store and access your connection strings this way.
Do it as suggested by Microsoft:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 286
1 OriginalGriff 269
2 ppolymorphe 78
3 Inimicos 60
4 ProgramFOX 50
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100