Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Friday, March 30, 2012

If i am using SqlCommand Class and the CommandType of it is Text, then will it add "sp_exe

If i am using SqlCommand Class and the CommandType of it is Text, then will it add "sp_executesql N" in front of the sql command automatically in fact, just like SqlDataAdapter?If you are using a CommandType of Text, just send the SELECT, INSERT, UPDATE or DELETE command. If you are using CommandType of StoredProcedure, just send the name of the stored procedure. To see exactly what is sent to the SQL Server, use SQL Profiler, which will allow you to capture the exact code sent, which will vary based upon whether you are using parameters, etc.|||that's means i still need to add "sp_executesql N" when i use SqlCommand class and CommandType is Text if i want a better performance?|||As Douglas already suggested if you are not using a stored procedure then use command type text otherwise you should generally use command type stored procedure. You can however still use command type text to run a stored procedure whch does not return records, to do this it would be: "exec procname arg1, arg, arg..."

As for the sp_executesql this internal sql server procedure basically runs every single sql command received by the server. So yes, internally it is always added.

Friday, March 23, 2012

IDTSComponentEvents' events? When are they fired?

Hi everyone,

I was wondering when events inside IDTSComponentEvents interface are called when you throw a SSIS package? I've got a private class which implements IDTSEvents and along with that got another one that implements the IDTSComponentEvents. I see how neither of them are fired when I debug the code by using F11, and I don't know what is it for.

Let me know your comments or come back to me if you need further details on that.

Thanks in advance,

Any ideas?|||

From my usage, tasks use IDTSComponentEvents. You do not generally implement this yourself, but implementations of it are passed to you in suitable methods such as the TaskHost.Execute method which you override when building a task. It allows you to fire events within the tasks's execute method.

IDTSEvents on the other hand I use when executing a package. I implement that in a class, and then handle the events through the IDTSEvents.OnEvent methods. Never had a problem setting breakpoints in my class to track progress during execution.

You may also want to implement IDTSLogging and use that alongside IDTSEvents when executing a package.

|||Thanks Darren for your comments.