asp.net-mvc-3 – 使用connectionStringName进行数据库日志记录
发布时间:2020-12-16 00:12:51 所属栏目:asp.Net 来源:网络整理
导读:这是我的nlog.config文件.我已经打开了throwsException. nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" targets target type="Database" name="databaseLog" d
这是我的nlog.config文件.我已经打开了throwsException.
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true"> <targets> <target type="Database" name="databaseLog" dbProvider="sqlserver" connectionstring="server=.SQLExpress;database=Movie;integrated security=true"> <commandText> INSERT INTO [Log] ([Description],[Level] ) VALUES (@Description,@Level ) </commandText> <parameter name="@Description" layout="${message}"/> <parameter name="@Level" layout="${level}"/> </target> </targets> <rules> <logger name="*" minLevel="Trace" appendTo="databaseLog"/> </rules> </nlog> 这将工作并将记录插入数据库.但是我想使用connectionstringName而不是重新键入connectionstring. connectionstring="server=.SQLExpress;database=Movie;integrated security=true" 至 connectionStringName="ApplicationConnectionString" 我收到一个错误 解决方法
将System.Data.SqlClient添加到web.config / app.config中连接字符串中的ProviderName属性:
<add name="ApplicationConnectionString" providerName="System.Data.SqlClient" connectionString="server=.SQLExpress;database=Movie;integrated security=true;"/> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – ASP.NET MVC – Cascading Drop Down
- 如何缓存输出的action方法,返回图像到asp.net mvc中的视图?
- asp.net-mvc – 程序集使用System.Web.Http 5.1,它比引用的
- ASP.NET ViewState的工作原理
- asp.net-mvc – 具有Knockout和Web API的ASP.NET MVC:是否
- asp.net-mvc – 将集合传递给EditorFor()时,它会为输入元素
- asp.net-mvc – 在做PostAsync时为什么等待不起作用?
- 具有虚拟目录的ASP.net母版页中的基本URL
- asp.net-mvc-3 – 如何在asp.net mvc3中添加一组单选按钮
- asp.net-mvc – 升级到.Net 4.5和osFamily 3后无法启动Azur
推荐文章
站长推荐
- asp.net-mvc – ASP.NET中的Response.Write是一个
- asp.net – “DataView未在System.data中标记为可
- 实现对Asp.NetMvc及Asp.NetCore的权限控制
- 在.NET Core中使用简单的插件化机制
- asp.net-web-api – 在asp.net web api中将HL7 F
- asp.net-mvc – 使用响应流的MVC控制器
- .net – 如何从ModelState键中删除前缀?
- asp.net-mvc – 不要在ASP .NET MVC 4 BundleCon
- asp.net-mvc-4 – 自定义多态模型绑定程序不绑定
- ASP.NET Web服务命名空间子域是否重要?
热点阅读