我无法找到适合Microsoft SQL服务器的连接字符串,它是2014开发人员版。 我目前的提供商是:
string strAccessConn = "Provider=SQLNCLI11;Data Source=10.211.55.7;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User Id=pos;Password=password;";
然而,我收到此错误, Error
供参考,这是我的源代码。
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();
}
我想使用OleDbConnector。
谢谢!
答案 0 :(得分:0)
要测试,请尝试添加连接:msdn.microsoft.com/en-us/library/ms171887.aspx
"单击“值”字段中的省略号(...)按钮以打开“连接属性”对话框以构建连接字符串"
有魔法"