C# oledb连接异常
这是我的密码C# oledb连接异常,c#,sql-server,sql-server-2008,oledb,C#,Sql Server,Sql Server 2008,Oledb,这是我的密码 string connectionString = @"Provider=SQLOLEDB;Data Source=Machine Name;Initial Catalog=MyTestDatabase;"; OleDbConnection conn = new OleDbConnection(connectionString); DataTable result = new DataTable(); try { conn.Open(); OleDbCommand
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{“无效授权规范”}
连接打开()
在
连接字符串中没有用户名
和密码
请尝试此连接字符串
Provider=SQLOLEDB;Data Source=Machine Name;Initial Catalog=MyTestDatabase;Integrated Security=SSPI
如果无法在本地工作-则您无法访问Sql Server连接字符串格式:
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
或
将
integratedsecurity=SSPI
添加到连接字符串中,尤其是在未指定用户名和密码的情况下。在这种情况下,当前凭据用于身份验证
Provider=SQLOLEDB;Data Source=ServerName;Integrated Security=SSPI;Initial Catalog=databaseName
如何连接到sql server?通过windows身份验证或sql server身份验证?我在同一网络中的另一台计算机上使用了相同的格式。在这里,我试图连接到我正在工作的同一个系统中的服务器,以帮助您使用任何连接字符串。同时将您的conn放入using中,以便将其释放。它的格式必须仍然正确,如果未指定用户名密码,则可以指定集成安全性您使用登录密码或Windows身份验证吗?
Provider=SQLOLEDB;Data Source=ServerName;Integrated Security=SSPI;Initial Catalog=databaseName