MyConnection=New SQLConnection(System.Configuration.ConfigurationSettings.AppSettings["data"]);

解决方案 »

  1.   

    to zwztu,按照您说的,我改了但出现如下错误:编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: BC30311: 类型“System.Collections.Specialized.NameValueCollection”的值无法转换为“String”。源错误: 行 21: 'Config = Context.GetConfig("appSettings")
    行 22: 'MyConnection = New SQLConnection(Config("strConn"))
    行 23:  MyConnection=New SQLConnection(System.Configuration.ConfigurationSettings.AppSettings["strConn"]);
    行 24: 
    行 25: '  MyConnection = New SqlConnection("server=WEBOPENOUT\NetSDK;UID=sa;PWD=;DATABASE=zcgmMIS")
     源文件: c:\inetpub\wwwroot\zcgmMIS\WebForm1.aspx    行: 23 显示详细的编译器输出:
    C:\WINNT\system32> "c:\winnt\microsoft.net\framework\v1.0.3705\vbc.exe" /t:library /utf8output /R:"c:\winnt\assembly\gac\system\1.0.3300.0__b77a5c561934e089\system.dll" /R:"c:\winnt\assembly\gac\system.data\1.0.3300.0__b77a5c561934e089\system.data.dll" /R:"c:\winnt\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"c:\winnt\microsoft.net\framework\v1.0.3705\temporary asp.net files\zcgmmis\8a758207\b07fd1c7\assembly\dl\0c972c0d\707f32a5_88f5c201\zcgmmis.dll" /R:"c:\winnt\assembly\gac\system.xml\1.0.3300.0__b77a5c561934e089\system.xml.dll" /R:"c:\winnt\assembly\gac\system.web.services\1.0.3300.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\winnt\assembly\gac\system.drawing\1.0.3300.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\winnt\microsoft.net\framework\v1.0.3705\temporary asp.net files\zcgmmis\8a758207\b07fd1c7\qzclnjbn.dll" /R:"c:\winnt\microsoft.net\framework\v1.0.3705\temporary asp.net files\zcgmmis\8a758207\b07fd1c7\hgidbxqc.dll" /R:"c:\winnt\assembly\gac\system.web\1.0.3300.0__b03f5f7f11d50a3a\system.web.dll" /out:"C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\zcgmmis\8a758207\b07fd1c7\ates7w_j.dll" /D:DEBUG=1 /debug+  "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\zcgmmis\8a758207\b07fd1c7\ates7w_j.0.vb"
    Microsoft (R) Visual Basic .NET 编译器版本 7.00.9466
    用于 Microsoft (R) .NET 框架版本 1.00.3705
    版权所有 (C) Microsoft Corporation 1987-2001。保留所有权利。c:\inetpub\wwwroot\zcgmMIS\WebForm1.aspx(23) : error BC30311: 类型“System.Collections.Specialized.NameValueCollection”的值无法转换为“String”。 MyConnection=New SQLConnection(System.Configuration.ConfigurationSettings.AppSettings["strConn"]);
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             
    c:\inetpub\wwwroot\zcgmMIS\WebForm1.aspx(23) : error BC30203: 需要标识符。 MyConnection=New SQLConnection(System.Configuration.ConfigurationSettings.AppSettings["strConn"]);
                                                                                           ~~~~~~~~~    
      

  2.   

    Config("strConn")
    你能保证这个东西就是合法的字符串??如果是你想要的字符串,因为你config是个hashtable
    也得加上toString()
      

  3.   

    to lilyfirstone(永恒......)    我还不懂,请问应该如何加上tostring()源码是这样的:
      Dim MyConnection As SQLConnection 
      Dim Config as HashTable
      Config = Context.GetConfig("appSettings")
      MyConnection = New SQLConnection(Config("strConn"))
      MyConnection.Open()