最近、Visual Studio 2010 で asp.net ページを作成しました。ビルド済みの loginview コードは変更していません。ユーザーのログインとユーザーの登録を可能にする MDF ファイルを作成します。ただし、MDF ファイルは使用したくありません。実行中の SQL Server インスタンス (MyServer と呼びましょう) をデータベース MyDatabase と共に使用したいと考えています。MDF ファイルに接続するコードはどこにありますか? また、データ ソースを変更するクリーンな方法はありますか? ありがとう!
1 に答える
1
で変更できstring connection
ますconfig file
(Web.config)
このセクションを変更します
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=../File.mdf; Integrated Security=True;Connect Timeout=30;User Instance=True;Trusted_Connection=Yes"/>
</connectionStrings>
たとえばこれで
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"/>
</connectionStrings>
于 2012-09-28T13:06:47.050 に答える