我编写了CLR SQL触发器来从数据库获取数据并使用rest api发布到其他网站。当我使用插入查询手动插入时,它正在工作。 但是我从HP ALM站点创建了缺陷我只得到了缺陷ID剩下的列就像空了。 请找到以下代码和
CREATE TRIGGER tri_Publishes_clr
ON td.BUG
for INSERT
AS
EXTERNAL NAME triggertestwebapi.CLRTrigger.showinserted
CREATE ASSEMBLY triggertestwebapi
FROM 'D:\hackthon\CLRTrigger\CLRTrigger\bin\Debug\CLRTrigger.dll'
WITH PERMISSION_SET = UNSAFE
public static void showinserted()
{
SqlTriggerContext triggContext = SqlContext.TriggerContext;
SqlConnection conn = new SqlConnection(" context connection =true ");
conn.Open();
SqlCommand sqlComm = conn.CreateCommand();
SqlPipe sqlP = SqlContext.Pipe;
SqlDataReader dr;
sqlComm.CommandText = "SELECT BG_BUG_ID,BG_SUMMARY from inserted";
dr = sqlComm.ExecuteReader();
string postData=string.Empty;
string comment = "User Story:23;24";
while (dr.Read())
{
// sqlP.Send((string)dr[0]);//+ "," + (dr[1] = DBNull.Value) ? string.Empty : dr[1].ToString());
comment = (dr[0]==DBNull.Value?string.Empty:dr[0].ToString())+(dr[1] == DBNull.Value ? "venkat" : dr[0].ToString());
sqlP.Send(comment);
}
先谢谢了, Venkat