Microsoft SQL Server 2014 over network. Oledb Connection String

依然范特西╮ 提交于 2019-12-12 03:19:50

问题


I cannot find an appropriate connection string to a Microsoft SQL server, it's the 2014 developer edition. My current provider is this:

string strAccessConn = "Provider=SQLNCLI11;Data Source=10.211.55.7;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User Id=pos;Password=password;";

However, I get this error, Error

For reference, this is my source code.

string strAccessConn = "Provider=SQLNCLI11;Data Source=10.211.55.7,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User Id=pos;Password=password;";
string strAccessSelect = "SELECT userid FROM users";

DataSet myDataSet = new DataSet();
OleDbConnection myAccessConn = null;
try
{
    myAccessConn = new OleDbConnection(strAccessConn);
}
catch (Exception ex)
{
    Console.WriteLine("Error: Failed to create a database connection. \n{0}", ex.Message);
    Console.ReadLine();
}

try
{
    OleDbCommand myAccessCommand = new OleDbCommand(strAccessSelect, myAccessConn);
    OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);

    myAccessConn.Open();
    myDataAdapter.Fill(myDataSet, "Police");
}
catch (Exception ex)
{
    Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
    Console.ReadLine();
    return;
}
finally
{
    myAccessConn.Close();
}

I want to use the OleDbConnector.

Thank you!


回答1:


Just to test, try adding the connection thus : msdn.microsoft.com/en-us/library/ms171887.aspx

" Click the ellipses (...) button in the Value field to open the Connection Properties dialog box to build your connection string "

There's the "magic"



来源:https://stackoverflow.com/questions/27326118/microsoft-sql-server-2014-over-network-oledb-connection-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!