私はVisualStudio2008でC#Windowsプログラムに取り組んでいます。通常、私は学校から直接USBドライブで作業しています。しかし、自宅のハードドライブにフォルダをコピーすると、データベースに書き込もうとすると、SQL例外が処理されなくなります。conn.Open()で処理されません。ライン。これが未処理の例外です
データベース'L:\ system \ project \ the_project \ the_project \ bin \ Debug\PatientMonitoringDatabase.mdf'は既に存在します。別のデータベース名を選択してください。ファイル'C:\ Documents and Settings \ Administrator \ My Documents \ system \ project \ the_project \ the_project \ bin \ Debug\PatientMonitoringDatabase.mdf'をデータベース'PatientMonitoringDatabase'として添付できません。
接続文字列に|DataDirectory|と表示されているので、どのドライブでも機能するはずです...接続文字列は次のとおりです。
string connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\PatientMonitoringDatabase.mdf; " +
"Initial Catalog=PatientMonitoringDatabase; " +
"Integrated Security=True";