Follow us on Twitter!
Become the change you seek in the world. - Gandhi
Friday, April 18, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 10
Guests Online: 9
Members Online: 1

Registered Members: 82822
Newest Member: TheBunter
Latest Articles
View Thread

HellBound Hackers | Computer General | Webmasters Lounge

Author

Yet another SQL Question...


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 13-06-08 17:51
i have a clr stored procedure written in c# that starts a thread to call a certain command asynchronously. the command is given as a parameter like so:
Code
 exec sp_processor [insert command]




now this works perfectly when run manually. smooth and accomplishes the asynchronous behavior i want. however when i put it into my trigger code it never runs although the trigger fires perfectly.

here's the trigger code
Code

ALTER TRIGGER [dbo].[trig_newRow] ON [dbo].[TestTable]
AFTER INSERT
AS
DECLARE @row int
DECLARE @cmd varchar(50)
SET @row = (SELECT TestIndex FROM INSERTED)
SET @cmd = 'exec sp_initiateJob '+CONVERT(VARCHAR(20), @row)

PRINT 'Command:'+@cmd
PRINT 'Trigger fired...'
EXEC sp_processor [@cmd]
PRINT 'sp_processor shoulda fired...




the print statements are for debugging and all the print statements are called fine.. also i put in other stored procedures to execute even another written in c# and those run perfectly.

as long as i'm here i might as well post the c# code so you can tell me if there is a problem with that. here it is:
Code

using System;
using System.Threading;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;

public class FileTrigger
{
    private static SqlConnection cnn;
    private static string command;

    [SqlProcedure]
    public static void processRow(string cmd)
    {
            try
            {
                cnn = new SqlConnection(getConnectionString());
                cnn.Open();
                command = cmd;
                Thread processor = new Thread(process);
                processor.Start();
            }
            catch
            {
                getConnectionString();
            }
    }

    private static void process()
    {
        SqlCommand cmd = new SqlCommand(command, cnn);
        cmd.ExecuteNonQuery();
        cnn.Close();
    }

    private static string getConnectionString()
    {
        return "Data Source=xxx.xxx.x.xx;Initial Catalog=xxxxxxx; User ID=xxxxxxx; Password=xxxx";
    }
}





so why will this run manually like a charm but right when put into the trigger it doesn't run.. Thanks in advance.

Jake




Edited by on 13-06-08 17:53
Author

RE: Yet another SQL Question...


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 19-06-08 18:36
have you checked the permissions?