I have tested this application many times, but all of a sudden it threw an error like this, while running the app:
'''System.Data.SqlClient.SqlException: 'The server principal "domain\user" is not able to access the database "db2" under the current security context.' '''
The database name "db2" is not the name of the database referenced inside the application.
The place in the application where it threw the error was here:
private List<DBInvoiceModel> GetInvoiceRecords(int orderNumber)
{
// "vsView"
var dbConnection = new SqlConnection("Data Source=domain;Initial Catalog=Test;Integrated Security=true");
dbConnection.Open();
var sqlCmd = dbConnection.CreateCommand();
sqlCmd.CommandText = @"SELECT
[ItemID]
,[TranNo]
,[STaxAmt]
,[TranAmt]
,[Status]
,[EDITranNum]
,[QtyShipped]
,[FreightAmt]
,[TrackingNumber]
,[ItemPrice]
FROM [Test].[dbo].[vsView]
WHERE EDITranNum = '" + orderNumber.ToString() + "'";
var reader = sqlCmd.ExecuteReader();
List<DBInvoiceModel> result = new List<DBInvoiceModel>();
while (reader.Read())
{
I checked with the IT Dept, they said no permissions changes have been made. Any ideas on how I could re-code this or refresh data connection? I have searched the Solution Explorer for the name of the database, in this case, "db2", however, it does not appear anywhere in the project.
I HAVE used the database referenced only in creating SSRS reports.