0

I have Stored Procedure in SQL that works in C# fine locally. When I publish my C# project and call that stored procedure, it do not work anymore.

My Connection String:

<add name="SqlConnectionString" connectionString="Data Source=SERVER;Initial Catalog=BD;Integrated Security=True" providerName="System.Data.SqlClient" />

Calling the Stored Procedure:

SqlConnection sqlCon = null;
String SqlconString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;

using (sqlCon = new SqlConnection(SqlconString))
{
  sqlCon.Open();
  SqlCommand sql_cmnd = new SqlCommand("Actualizar_Avaliacoes_Servicos", sqlCon);
  sql_cmnd.CommandType = CommandType.StoredProcedure;
  sql_cmnd.ExecuteNonQuery();
  sqlCon.Close();
}

Error Fail Login

Suraj Kumar
  • 5,547
  • 8
  • 20
  • 42
get a life
  • 21
  • 6
  • Use Sql Server Authentication instead of Windows Authentication, by setting "Integrated Security=false; User Id=[user_name];Password=[pass]" into connection string. – Nazar Mandzyk Jan 13 '20 at 17:17

1 Answers1

2

You have a web application does not have rights to connect to the database. You will need to do one of 2 things.

  1. Change your connection string to store the username and password. How to set username and password in connection string for connecting to database?
  2. Launch IIS Manager and change the settings for the application's pool so it runs as a user with database rights. Add IIS 7 AppPool Identities as SQL Server Logons
Jason Geiger
  • 1,912
  • 18
  • 32