是不是你在引用时没有在web.config中写 key="constr"之类的呀?
<appSettings>
<add key="constr" value="Data Source=localhost;Initial Catalog=web;User ID=sa;Password=sa"/>
</appSettings>
<appSettings>
<add key="constr" value="Data Source=localhost;Initial Catalog=web;User ID=sa;Password=sa"/>
</appSettings>
请检查有没有大小写写错的地方,比如key键的值constr
断点跟一下这里,connection附上了没有?
<connectionStrings>
<add name= "webConnectionString " connectionString= "Data Source=localhost;Initial Catalog=web;User ID=sa;Password=sa "/></connectionStrings>
</configuration>
使这种各式的?
lye2000000_super兄弟说的对。