嗨我在从IIS运行项目时将记录插入数据库时遇到错误,我将通过Visual Studio运行它运行良好。
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
答案 0 :(得分:2)
您的网站将在没有权限的用户(应用程序池的权限)的上下文中运行,可能是NetworkService等。解决方案是创建一个对数据库具有相关权限的用户,并在连接字符串中明确说明凭据。
关于不要做什么的建议是这样的。不管怎样,不要试图让用户在这些权限下运行应用程序以使用集成安全性。这很糟糕。
答案 1 :(得分:1)
你是否检查了web.config中的连接字符串visual studio和IIS