问题
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