最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

sql server中調(diào)用c#寫的dll里的方法

標(biāo)簽:
SQL Server C#

最近有一项目:

一超市管理系统单机版,运行在WIN2003+SQL2005上,每天超市关门都都会关电脑,现客户要新加功能,每天关门下班后回家可以上网查看超市管理系统的数据库里的相关数据,然后再做一些原系统没有的统计分析等,老系统不能做大改动,像升级到WIN2012+SQL2012等这些操作,改动越小越好。

现在的想法是:阿里云买台服务器,装上SQL,然后建立的数据库和超市管理系统上的数据库一毛一样,然后想办法,当超市管理系统数据库里的增表增删改的时候,同步阿里云服务器上的数据库保持数据一致,

然后剩下的就是做自己的网站连接阿里云上的数据库做统计分析就好了

上网到处问网友,以前的技术经理给了如下方案:

using System.Text.RegularExpressions;

namespace MSSQLExtMethod
{
public class RegexExtends
{
[Microsoft.SqlServer.Server.SqlFunction]
public static bool IsMath(string input, string patten)
{
return !string.IsNullOrEmpty(input) && new Regex(patten).IsMatch(input);
}
[Microsoft.SqlServer.Server.SqlFunction]
public static string Math(string input, string patten)
{
return string.IsNullOrEmpty(input) ? "" : new Regex(patten).Match(input).Value;
}
[Microsoft.SqlServer.Server.SqlFunction]
public static string Replace(string input, string patten, string replace)
{
return string.IsNullOrEmpty(input) ? "" : new Regex(patten).Replace(input, replace);
}
}
}


create assembly Regex from 'E:\Test\Libs\MSSQLExtMethod.Regex\MSSQLExtMethod.Regex\bin\Debug\MSSQLExtMethod.Regex.dll' with permission_set = SAFE

exec sp_configure 'clr enabled',1
RECONFIGURE

create function [dbo].[Regex.Math](@Input nvarchar(max),@Regex nvarchar(max))
returns nvarchar(max) with execute as caller
as
external NAME [Regex].[MSSQLExtMethod.RegexExtends].[Math]
go

create function [dbo].[Regex.Replace](@Input nvarchar(max),@Regex nvarchar(max),@Replace nvarchar(max))
returns nvarchar(max) with execute as caller
as
external NAME [Regex].[MSSQLExtMethod.RegexExtends].[Replace]
go

create function [dbo].[Regex.IsMath](@Input nvarchar(max),@Regex nvarchar(max))
returns bit with execute as caller
as
external NAME [Regex].[MSSQLExtMethod.RegexExtends].[IsMath]
go


declare
@regex nvarchar(500)
,@replace nvarchar(500)
,@input nvarchar(500)
,@regex2 nvarchar(500)
,@input2 nvarchar(500)

select @regex = '^(1[3456789][0-9])[0-9]{4}([0-9]{4})$'
,@input = '13912345678'
,@replace = '$1****$2'

select @regex2='1[3456789][0-9]{6}'
,@input2='13100000000,13922222222'

select dbo.Regex.Replace
select dbo.Regex.Math
select dbo.Regex.IsMath

第一块代码,.net 类库,第二块代码类库注册到 MSSQL 中形成函数,第三块代码调用实例

今天自己测试了一下,发现只有.NET 2.0的DLL才可以,开始我是.NET 4.0的,总是报那个什么什么权限错误之类的。。

这样只要在SQL2005的表中加个触发器,有数据变动的时候就调用DLL里的方法访问远程接口进行增删改远程数据库就好了

另SQL非免费版里好像有个‘镜像’功能,和一个‘复制’功能,不知道能不能用,没有学过的。。。

自己在VS2W017中做的.NET 2.0的DLL示例方法的源码:

http://ohpxbzczu.bkt.clouddn.com/SQL2005ExecDLLDemo.zip

點擊查看更多內(nèi)容
3人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費專欄免費學(xué)

大額優(yōu)惠券免費領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消