连接到SQL Server Express 2014数据库的命名法是什么?

时间:2014-12-20 20:48:31

标签: oledbconnection

我正在连接到Access 2007数据库:

oleConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\...\\Db.accdb");

连接到SQL Server Express 2014数据库的命名法是什么?

1 个答案:

答案 0 :(得分:0)

string connectionString =
    "Provider=SQLOLEDB.1" + ";" +
    "Integrated Security=SSPI" + ";" + //Windows authentication
    "Persist Security Info=False" + ";" +
    "User Instance=True" + ";" +
    "Data Source=CTE-LAPTOP\\SQLEXPRESS" + ";" +
    "Initial Catalog=SqlServerDbExample" + ";" + //Database name
    "AttachDBFilename=C:\\..\\SqlServerDbExample.mdf" + ""; //Filename

OleDbConnection oleConnection = new OleDbConnection(connectionString);