是不是你在引用时没有在web.config中写 key="constr"之类的呀?
<appSettings>
<add key="constr" value="Data   Source=localhost;Initial   Catalog=web;User   ID=sa;Password=sa"/>
</appSettings>

解决方案 »

  1.   

    书写不一致
    请检查有没有大小写写错的地方,比如key键的值constr
      

  2.   

    cmd.Connection.Open()???
    断点跟一下这里,connection附上了没有?
      

  3.   

      另外我又存在一个比较棘手的问题,希望各位高人能指点一二。我想问vs中能否执行sql中的视图????
      

  4.   

    etuchang兄弟说的connection,是否command中的??command中有sql的连接语句。
      

  5.   

    <configSections>
    <connectionStrings>
      <add name= "webConnectionString "   connectionString= "Data   Source=localhost;Initial   Catalog=web;User   ID=sa;Password=sa "/></connectionStrings>
    </configuration>
    使这种各式的?
      

  6.   

    table[0].defaultView 这就是默认的视图
      

  7.   

    谢谢各位的答复!
    lye2000000_super兄弟说的对。
      

  8.   

    大家好,有个新问题需要和大家探讨,请高人指点要实现的功能是:选中DataGrid中某条记录后,记录中的信息自动回显到当前窗口的TextBox控件中去。谢谢!