I try to connect to Sql server database, but it said : “Login failed for user _cben” for line :
sqlCon.Open();
this is my code :
public static DataTable GetDataFromSqlDatabase(Dictionary<string, object> parameters, string nameOfStoredProcedure, string connectionString)
{
DataTable results = new DataTable();
using (SqlConnection sqlCon = new SqlConnection(connectionString))
{
sqlCon.Open();
using (SqlCommand sqlCom = sqlCon.CreateCommand())
{
sqlCom.CommandText = nameOfStoredProcedure;
sqlCom.CommandType = CommandType.StoredProcedure;
BuildSQLCommandParams(parameters, sqlCom);
results.Load(sqlCom.ExecuteReader());
}
}
return results;
}
and my connection string :
string connstr = "Data Source=CH-SQLDWV005;Initial Catalog=PWCGFA_COMMON;User ID=_cben;Password=_c...";
return DataProviderUtility.GetDataFromSqlDatabase(sqlParams, StoredProcedures.GETREASSESSMENTS,connstr);
but when I add a sql file, the connection works and it brings me results
