简体   繁体   中英

VS2012 C# SQL database error - improperly installed?

On computer A my project is working fine, but on computer BI get a SQL exception:

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 )

Every time I call the CreateDatabse() method (from Database class that inherits from DataContext class).

I already tried to reinstall the whole SQL Server - but the exception remained. I have SQL Server 2012 installed. List of my SQL related programs installed:

我安装的与SQL相关的程序列表

If it makes any difference, computer A is working under win8 and computer B on win7.

Database is created by program code:

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) { }
}

edit: My problem is still unsolved. I've tried to reinstall MS SQL one more time, with no effect.

当未正确配置连接字符串或计算机A上的防火墙阻止SQLServer在网络上正常运行时,会发生此问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM