connection属性尚未设置或为null [英] the connection property has not been set or is null
问题描述
即时开发winform并将我的连接存储在App.config中
< add key = CS value = < span class =code-string> Server = localhost; User ID = root; Password = 123456; Persist Security Info = True; Database = dbMember />
这就是我从C调用connectionString的方式
string CS = System.Configuration.ConfigurationManager.AppSettings.Get( CS);
是的,它可以在我的机器上顺利运行,如何显示错误消息:连接属性尚未设置或为空,当我尝试在另一台PC上运行它时。
如果我手动编码这样的连接字符串,它可以在另一台PC上工作:
< pre lang =c#> string CS = Server = localhost; User ID = root; Password = 123456; Persist Security Info = True; Database = dbMember;
有什么建议吗?我已经在PC上安装了相同版本的sql
你不应该以这种方式存储和访问你的连接字符串。
按照Microsoft的建议执行: http://msdn.microsoft.com/ en-us / library / ms254494(v = vs.80).aspx [ ^ ]
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
You shouldn''t store and access your connection strings this way.
Do it as suggested by Microsoft: http://msdn.microsoft.com/en-us/library/ms254494(v=vs.80).aspx[^]
这篇关于connection属性尚未设置或为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!