在SQL2005中如何用触器实现到客户端的通知?我写了一个存储过程,用Socket发信息,但提示权限错误。郁闷,
存储过程是这样的:
-------------------------------
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Net;
using System.Net.Sockets;
using System.Text;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void SendMessage(string Msg)
{
// 在此处放置代码
TcpClient client = new TcpClient();
client.Connect(IPAddress.Parse( "221.7.229.*** "), 23456);
byte[] buffer = Encoding.ASCII.GetBytes(Msg);
client.GetStream().Write(buffer, 0, buffer.Length);
client.Close();
}
};
-------------------------------
错误提示是:
消息 6522,级别 16,状态 1,过程 SendMessage,第 0 行
在执行用户定义例程或聚合 'SendMessage ' 期间出现 .NET Framework 错误:
System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ' failed.
System.Security.SecurityException:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.Sockets.Socket.CheckCacheRemote(EndPoint& remoteEP, Boolean isOverwrite)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPAddress address, Int32 port)
at StoredProcedures.SendMessage(String Msg)
。
请高手帮忙呀,或都有什么更好的方法可用,谢告诉小弟,感激涕零。
------解决方案--------------------帮你顶下,我的问题也没有办法解决呀
------解决方案--------------------关注!