Reputation: 9633
Hi I am getting an Error while Inserting Record into databse while ruuning the Project from IIS and i will run through Visual Studio it is working well.
The INSERT permission was denied on the object 'tblPageInfo', database 'master', schema 'dbo'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The INSERT permission was denied on the object 'tblPageInfo', database 'master', schema 'dbo'.
Source Error:
Line 43: string s = "insert into tblPageInfo values('" + PageName + "','" + Url + "','" + PageTitle + "','" + CanonicalUrl + "','" + MetaDescription + "','" + MetaKeyword + "','" + H1Text + "','" + H2Text + "')";
Line 44: SqlCommand cmd = new SqlCommand(s, con);
Line 45: cmd.ExecuteNonQuery();
Line 46: con.Close();
Line 47: }
Source File: D:\Kartik\Materials\CMS\CMS\AddPage.aspx.cs Line: 45
Upvotes: 0
Views: 1502
Reputation: 1921
did you check the connection string in web.config both visual studio and IIS
Upvotes: 1
Reputation: 45058
Your website will be running in the context of a user that doesn't have permission (that of the application pool), likely NetworkService or such like. The solution is to create a user with relevant permissions on your database and explicitly state the credentials in the connection string.
A word of advice on what not to do is this. Don't, however tempted, give the user the application is running under those permissions in order to use integrated security. This is bad.
Upvotes: 2