I am trying to get data from SQL server's table in SharePoint custom web part.There I am getting error as
"Login failed for user 'NT AUTHORITY\IUSR'".
here is my simple code
DataTable table = new DataTable();
string ConnectionString= "Data Source=PC11;Initial Catalog=Employee;Integrated Security = SSPI";
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
Console.WriteLine("connection created successfuly");
string command = "SELECT * FROM Employees";
using (var cmd = new SqlCommand(command, conn))
{
Console.WriteLine("command created successfuly");
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
conn.Open();
Console.WriteLine("connection opened successfuly");
adapt.Fill(table);
conn.Close();
Console.WriteLine("connection closed successfuly");
}
}
Employee
database in SQL Server > DataBase > your Database > Security > Users