用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。 conn.Open();
// SqlCommand 对象, 使用conn作为数据连接
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn; cmd.CommandText = "SELECT CategoryID, CategoryName FROM Categories";
// 获取 SqlDataReader 实例
SqlDataReader reader = cmd.ExecuteReader(); // 输出结果
Console.WriteLine("{0}\t{1}", "CategoryID", "CategoryName");
Console.WriteLine();
while(reader.Read())
{
Console.WriteLine("\t{0}\t{1}", reader.GetInt32(0), reader.GetString(1));
} conn.Close();
}
catch(Exception e)
{
Console.WriteLine("无法连接到数据库!报告异常:");
Console.WriteLine(e.Message);
}
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。 conn.Open();
// SqlCommand 对象, 使用conn作为数据连接
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn; cmd.CommandText = "SELECT CategoryID, CategoryName FROM Categories";
// 获取 SqlDataReader 实例
SqlDataReader reader = cmd.ExecuteReader(); // 输出结果
Console.WriteLine("{0}\t{1}", "CategoryID", "CategoryName");
Console.WriteLine();
while(reader.Read())
{
Console.WriteLine("\t{0}\t{1}", reader.GetInt32(0), reader.GetString(1));
} conn.Close();
}
catch(Exception e)
{
Console.WriteLine("无法连接到数据库!报告异常:");
Console.WriteLine(e.Message);
}
SqlConnection conn = new SqlConnection(strConn); try
{
// 打开数据库连接
conn.Open();
// SqlCommand 对象, 使用conn作为数据连接
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn; cmd.CommandText = "SELECT CategoryID, CategoryName FROM Categories";
// 获取 SqlDataReader 实例
SqlDataReader reader = cmd.ExecuteReader(); // 输出结果
Console.WriteLine("{0}\t{1}", "CategoryID", "CategoryName");
Console.WriteLine();
while(reader.Read())
{
Console.WriteLine("\t{0}\t{1}", reader.GetInt32(0), reader.GetString(1));
} conn.Close();
}
catch(Exception e)
{
Console.WriteLine("无法连接到数据库!报告异常:");
Console.WriteLine(e.Message);
}
用户到底是谁呀。我是用SA做帐号的。怎么会是权限不够呀。