2012-05-11 12 views
1

私のASP.NET Webサイトに次のエラーがあります。私は別のPCに移動しました。 IISが起動し、SQL Server Express &がデータソースマシン名を新しいマシン名に変更しました。しかし、DBアクセスの任意のページで、私はスクリーンショットに示すエラーが表示されます。 Server error in ApplicationASP.NET DataContextの接続エラーを解決する方法

革新-news.aspxは、このように新しいのDataContextを作成します。

dataContext = new DataContext(Config.ConnectionString); 
マイConfigクラスが上のベースの接続文字列を返す

現在のIP。たとえば、次のように

web.configファイルである
return ConfigurationManager.ConnectionStrings["Development"].ConnectionString; 

<connectionStrings> 
<add name="Development" connectionString="Data Source=WORK51C0\SQLEXPRESS;Initial Catalog=Jri;Integrated Security=True;" providerName="System.Data.SqlClient"/> 
</connectionStrings> 

次はLinqToSql1.designer.cs

public DataContext() : 
      base(global::Jri.Data.Properties.Settings.Default.JriConnectionString1, mappingSource) 
    { 
     OnCreated(); 
    } 

    public DataContext(string connection) : 
      base(connection, mappingSource) 
    { 
     OnCreated(); 
    } 

    public DataContext(System.Data.IDbConnection connection) : 
      base(connection, mappingSource) 
    { 
     OnCreated(); 
    } 

    public DataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
      base(connection, mappingSource) 
    { 
     OnCreated(); 
    } 

    public DataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
      base(connection, mappingSource) 
    { 
     OnCreated(); 
    } 

からこれをデバッグする最善の方法上の任意のアドバイスですか?または、おそらくあなたは何が間違っているか知っていますか?

ありがとう、

+0

WORK51C0は新しいワークステーションの名前ですか?そのインスタンス名を持つSQL Expressを持っていて、統合セキュリティがオンになっていますか? SQL Server Management Studioに接続できますか? – driis

+0

は 'connection'または' mappingSource' nullですか? –

+0

Jri.Data.DataContactはLinq.DataContextから派生していますか?私たちはもう少し詳しい情報を使用することができます... –

答えて

0

OKこれは、ConfigurationManagerでMy Configクラスにアクセスする際の問題でした。だから私の一時的な解決策は、web.configから取得しようとするのではなく、このクラスが直接出力する接続文字列を持つことでした。

0

これはArgumentNullExceptionです。あなたは何とかnullをコンストラクタまたはDataContextに渡しています。

デバッガを接続し、Config.ConnectionStringまたはmappingSourceがnullを返す理由を確認してください。

関連する問題