jmp连mysql_简单源码适合学习_C# 后台服务监控SQL Server数据库表改动并同步到MySQL数据库表...

本文介绍了一个使用C#编写的Windows服务应用程序,该程序通过SqlTableDependency库监控SQL Server数据库的表变化,并将这些变化实时同步到MySQL数据库。主要功能包括:初始化依赖、监听数据更改事件、保存更改到MySQL以及错误处理。源码适用于学习Windows服务和数据库同步。
摘要由CSDN通过智能技术生成

需求1.    将A服务器的sqlserver数据库item_mst表的数据同步到MySQL数据库Part表2.    监控Item_mst表中item,description,overview 的更改并同步到MySQL数据库 针对需求一,基本就是执行一次,单独写了个winform用来做这事针对需求二,写了个Windows service app

帮别人整得,挺简单的代码,用来学习Windows Service app 不错。

求点热心值,谢谢了!!!如有违规,删除即可。

Nuget安装

55fd2b2273b5a8b4531f72773c469d6e.gif

2.png (89.95 KB, 下载次数: 1)

2019-7-26 15:05 上传

Dapper就是个ormSerilog用来记logSQLTableDependency用来检测表的改动,文档地址:https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency使用这个别忘了执行 alter database [] set enable_broker with rollbackimmediate;1.创建service2.添加安装程序3.如何安装serviceCreate a Windows service apphttps://docs.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer How to: Add Installers to Your Service ApplicationHow to: Install and uninstallWindows services源码目录结构

55fd2b2273b5a8b4531f72773c469d6e.gif

1.png (41.25 KB, 下载次数: 0)

2019-7-26 15:06 上传

Models文件夹里的ItemMst.cs文件

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;

namespaceSyncItemMstAllService.Models

{//tablename: item_mst///note:We do not need to specify all table columns but just the ones we areinterested:///publicclassItemMst{// internalNumberpublicstringItem {get;set; }// namepublicstringDescription {get;set; }// descriptionpublicstringOverview {get;set; }}

}App.config

  AllowUser

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值