在計算機A上我的項目工作正常,但在計算機B上我得到一個SQL異常:VS2012 C#SQL數據庫錯誤 - 安裝不正確?
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我每次調用CreateDatabse()
方法(從Database
類從DataContext
類繼承)。
我已經嘗試重新安裝整個SQL Server - 但仍然存在異常。我安裝了SQL Server 2012。我的SQL相關程序的列表安裝:
如果這有什麼差別,A計算機工作的win8和B電腦下的WIN7。
數據庫是通過程序代碼創建:
String FOLDER_PATH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProgramName");
Directory.CreateDirectory(FOLDER_PATH);
String path = Path.Combine(FOLDER_PATH, "database.mdf");
Database db = new Database(path);
bool exists = db.DatabaseExists();
if (exists == false)
db.CreateDatabase();
public class Database : DataContext
{
public Table<Record> RecordTable;
public Database(string connection) : base(connection) { }
}
編輯:我的問題仍然沒有解決。我試圖重新安裝MS SQL一次,沒有任何效果。
你有實際* *數據庫在計算機B上? – Thousand
@千 - 數據庫是由程序創建的。我會將該代碼添加到原始帖子中。 –
你可以把你的連接字符串放在這裏嗎? –