这是我的代码
string connectionString = @"Provider=SQLOLEDB;Data Source=Machine Name;Initial Catalog=MyTestDatabase;";
OleDbConnection conn = new OleDbConnection(connectionString);
DataTable result = new DataTable();
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("get_holidays", conn);
cmd.CommandType = CommandType.StoredProcedure;
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(result);
}
$ exception {“无效的授权规范”}在此期间抛出 conn.open()。
答案 0 :(得分:2)
连接字符串格式:
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
或
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
答案 1 :(得分:1)
将Integrated Security=SSPI
添加到您的连接字符串,尤其是在未指定用户名和密码时。在这种情况下,当前Windows account凭据用于身份验证。
Provider=SQLOLEDB;Data Source=ServerName;Integrated Security=SSPI;Initial Catalog=databaseName
答案 2 :(得分:0)
username
password
和connection string
答案 3 :(得分:0)
尝试此连接字符串
Provider=SQLOLEDB;Data Source=Machine Name;Initial Catalog=MyTestDatabase;Integrated Security=SSPI
如果无法在本地运行 - 那么您无法访问您的Sql Server