解决方案 »

  1.   

    Server=192.168.1.2,1433;initial catalog=baseEn;user id=sa;password=sa
      

  2.   

    http://daview.cnblogs.com/archive/2004/04/10/5763.html
    看看这个是不是有帮助吧。
      

  3.   

    Server=192.168.1.2,1433;initial catalog=baseEn;user id=sa;password=sa
    这个是你复制的还是输入的?如果是复制的。那么你那个逗号貌似是全角的啊
      

  4.   

    System.NullReferenceException.
    这是有未将对象引用实例的错误,是哪个对象为null了
    你改成这样的链接字符串试试Data Source=192.168.1.2;Initial Catalog=baseEn;Persist Security Info=True;User ID=sa;Password=sa;
      

  5.   

    我刚刚把try块去掉了 出现的是这个错误
    未处理的“System.TypeInitializationException”类型的异常出现在 System.Data.dll 中。
    其他信息: “System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常。
      

  6.   

    好吧所有的异常
    在 System.Configuration.ConfigurationErrorsException 中第一次偶然出现的“System.Configuration.dll”类型的异常
    在 System.Configuration.ConfigurationErrorsException 中第一次偶然出现的“System.Configuration.dll”类型的异常
    在 System.Configuration.ConfigurationErrorsException 中第一次偶然出现的“System.Configuration.dll”类型的异常
    在 System.TypeInitializationException 中第一次偶然出现的“System.Data.dll”类型的异常
    在 System.TypeInitializationException 中第一次偶然出现的“System.Data.dll”类型的异常
    在 System.TypeInitializationException 中第一次偶然出现的“System.Data.dll”类型的异常
    未处理的“System.TypeInitializationException”类型的异常出现在 System.Data.dll 中。其他信息: “System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常。
      

  7.   

    连接字符串不对吧。
    "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog= pubs;UserID=sa;Password=asdasd;
    参考这样的。。
      

  8.   

    现在是这个异常
    未处理的异常:  System.TypeInitializationException: “System.Data.SqlClient.SqlCo
    nnection”的类型初始值设定项引发异常。 ---> System.TypeInitializationException:
    “System.Data.SqlClient.SqlConnectionFactory”的类型初始值设定项引发异常。 --->
    System.TypeInitializationException: “System.Data.SqlClient.SqlPerformanceCounte
    rs”的类型初始值设定项引发异常。 ---> System.Configuration.ConfigurationErrorsEx
    ception: 配置系统未能初始化 ---> System.Configuration.ConfigurationErrorsExcepti
    on: 无法识别的配置节 system.serviceModel。 (C:\WINDOWS\Microsoft.NET\Framework\v
    2.0.50727\Config\machine.config line 164)
       在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignor
    eLocal)
       在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(Configurat
    ionSchemaErrors schemaErrors)
       在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
       在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
    )
       --- 内部异常堆栈跟踪的结尾 ---
       在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
    )
       在 System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(S
    tring sectionName)
       在 System.Configuration.ClientConfigurationSystem.System.Configuration.Intern
    al.IInternalConfigSystem.GetSection(String sectionName)
       在 System.Configuration.ConfigurationManager.GetSection(String sectionName)
       在 System.Configuration.PrivilegedConfigurationManager.GetSection(String sect
    ionName)
       在 System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
       在 System.Diagnostics.DiagnosticsConfiguration.Initialize()
       在 System.Diagnostics.DiagnosticsConfiguration.get_SwitchSettings()
       在 System.Diagnostics.Switch.InitializeConfigSettings()
       在 System.Diagnostics.Switch.InitializeWithStatus()
       在 System.Diagnostics.Switch.get_SwitchSetting()
       在 System.Diagnostics.TraceSwitch.get_Level()
       在 System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryNam
    e, String categoryHelp)
       在 System.Data.SqlClient.SqlPerformanceCounters..ctor()
       在 System.Data.SqlClient.SqlPerformanceCounters..cctor()
       --- 内部异常堆栈跟踪的结尾 ---
       在 System.Data.SqlClient.SqlConnectionFactory..cctor()
       --- 内部异常堆栈跟踪的结尾 ---
       在 System.Data.SqlClient.SqlConnection..cctor()
       --- 内部异常堆栈跟踪的结尾 ---
       在 System.Data.SqlClient.SqlConnection..ctor()
       在 System.Data.SqlClient.SqlConnection..ctor(String connectionString)
       在 ipDb.Program.getConnection() 位置 E:\vswork\ipDb\ipDb\Program.cs:行号 54
       在 ipDb.Program.searchById() 位置 E:\vswork\ipDb\ipDb\Program.cs:行号 65
       在 ipDb.Program.Main(String[] args) 位置 E:\vswork\ipDb\ipDb\Program.cs:行号
    12
      

  9.   

    你用SQL客户端管理工具连看看
    用VS的“数据”》“新建数据库连接”,输入目标主机及口令,让工具生成连接串,然后再连看看
      

  10.   

    这个方法好 应该能看到生成的字符串 但是我还是悲剧了 提示调用目标发生异常会不会是安装vs2005和sqlserver2005时造成的
      

  11.   

    App.config 配置错误,一定要XML配置正确否则就出这个错误!