Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# oledb连接异常_C#_Sql Server_Sql Server 2008_Oledb - Fatal编程技术网

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