Home » C# Programming

How To Get Insert count,TotalRecords count and updated Count in SendMail Task?

Hi All,

I have one logtable.In log table i have insert_count,Total_Records_count and Updated_Count column's.I need those information in my mail.If the package executed sucessfully i need those info my mail.Please help me with this issue.






5 Answers Found


Answer 1

you mentioned that you have them in a table

make 3 variable ( uVar_input , uVar_ErrorRecords, uVar_Update ) use a SQL Task and run a select on the table  and populate the variables

use a uVarStr to make you string to display in the email , and concat the variables with it , and simply set the uVarStr to the MessageSource of the emailobject .

good luck


Answer 3

u would have to use expressions to set up the mail  body

Answer 5

Thank you all i will try...


Hi All,

To maintain inserts and updates i am using lookup and condition split transformation.Every thing is fine.I need how many records are inserted and updated information in ssis log table.Whenever i am executing the package in log table package startime and endtime everything in log table in same table i want inserts count and updates count also? how to implement this task?






I want to create a wrokflow which will count how many times tasks are assigned to user in one list and update that value in another list for that user.


List1: User, TaskId

List2: User, No of TaskAssigned

So my workflow will be on Task1. And It will update value to List2's No. of TaskAssigned.


How can I do this.?

- Is it possible using SharePoint Designer.?

- If Not, how can I do it in VS 2008.?




 I wants to have a CCMail for the sendmail task which should be configurable. The Expressions has only ToLinel and Message options only.

 So how should I add a CCline which should be configurable


I have some very bizarre behaviour in my sendmail, firstly I get no errors when the whole thing runs.

If I set my attachments within the sendmail task itself then the mail sends and I get the attachments.

If I cut the location(s) from the Sendmail attachments text box into a variable and then link the variable to the FileAttachments expression then I receive the mail but without attachments, initially I thought this might be because the filenames had spaces in but no, that didn't work, I've tried adding quotes to the entire string, each file location, etc and nothing. Does anyone have any idea why this could be? I'm guessing it's down to the attachment locations not being recognised (ie it's interpretation of the locations can't find the files) but what does it need to be able to find them?

The string is:

E:\SSRS Output\Marketing\DailyCategoryReport.xls|E:\SSRS Output\Marketing\DailyLoginReport.xls


Thanks in advance.




I had a package executing fine in BIDS and as a SQLAgent JOB.  After last night, the package still runs fine, but fails at SendMail Task ONLY with following error:

Code: 0xC002F304

   Source: Send Warning Notification Send Mail Task

   Description: An error occurred with the following error message: "Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender".

Not sure what would have changed in a night, the Database Mail is able to send an Email to myself successfully, but the SendMail Task fails.

The SMTP Server is valid, and I am emailing only Internal emailaddresses within the domain. 

Can anybody suggest which change of settings would result in this error




I am trying to make a trigger for INSERT, UPDATE.  For INSERT you get a table named inserted that you can use, and for UPDATE you get updated.  But what is the name if you doing a trigger for both?


If I create a data tabe in C# like so:

datatable t = new DataTable;

DataColum C1 = new DataColum;//ID column


//the same with column C2

Then I fill up the table with some data.

Then the goal is to either insert this data or update data in an SQLtable in SQL. If the data is inserted, the ID column in t would be empty, if updated, it would not be. So in the insertion case, the sql query needs to make sure that unique IDs are assigned during insertion, in the update case, it just has to look for the right IDs.

How to go about this?

Asking because I am only familiar with updating and inserting single lines into a table. One could loop in C# over the datatable t of course and insert or update line by line, but this would probably be slow. Is there a way to write an SQL query like this somehow:

Insert Into SQLTable Values (@t)


And Update like this:

Update SQLTable SET ... Where C1 = @t.C1

Or something like that.

I know that SQL server can create automatic update and insert queries and that you can then type things in C# like


But, this has proven to be super slow on our server, for unknown reasons. I have asked on this forum and got some answers from experts, but was not able to srot out the problem.

How can we write a custom SQL query that allow updating and inserting a whole table, instead of just one line at a time?

Thank you.



MOPS 2007  12.0.6513.5000 SP2 MSO (12.0.6425.1000)

Fixed Duration Tasks with assigned work and one resource.  Calculation Options set to that the end of completed work moves just to the left of the Status Date.  Calculation automatic.

When Actual Work is updated in a task, the completed portion moves to the left of the Status Date, as desired.

When the Actual work is entered through My Tasks (Exit client, Update Actual Work in My Tasks, Submit, Open Client, Accept updates),  the task seems to be stuck.  It's completed part doesn't move to the left of the Status Date and the task doesn't level (doesn't move at all).  (Priority is the default 500 like all the tasks.)  All this in a fresh 5 task project.

HOWEVER, entering a number into the Actuals ... entering 3 days when the actuals are already 3 days (so no change) ... seems to trigger something that "unsticks" the task and the completed part jumps to the level of the status date (as desired) and it levels properly.

Is this a known behavior/defect?  Is there a work around?  ... other than nudging the task for setting Actual = Actual or the like?

Hi, we are using PS 2007 and have noted that when a PM rejects an update the TM gets the rejected task notification (red cross) in my tasks. In this particular case the Team Member has proposed revised start and finish dates. If the PM rejects these there does not seem to be any way for the TM to see the original start and finish dates from PWA as the rejected dates still display until the TM resubmits a variation on these. BTW we are using %complete tracking not timephased actuals. Any ideas appreciated...


I wonder if someone can help me please.  We have a Workflow that creates a task and sends an e-mail notification to the approver. The Approver receives an e-mail and the Edit task form pops up with the correct information.

When the approver clicks Edit Task we get "This task could not be updated at time time" error when approver clicks submit button.

Upon searching the forum I found this article http://support.microsoft.com/kb/970199  however as the user doesn't have infopath 2007 (only has basic Office 2007) we cannot install the Forms Installer Tool.

Is there any way around this such as turning off the need for Infopath Forms?  When they try directly from the Sharepoint Server it works as this I believe uses Forms Services so Infopath is not required.

So I just wondered if we can turn off the dependancy of Infopath Forms in this instance?





I found this issue and I am not sure if this is how the OOTB Item-Level Permission is supposed to work.

Environment: MOSS Enterprise, IE7

I have two issues around the task list:

I have a task list where the item level permission is set to edit access: only thier own. 
A user who has the ootb permission level Approve or less can click on Edit Item for an item which is assigned to them but not created by them. The edit page opens and they can make modifications. However when they click OK they get the screen: Error Access Denied. 

The other issue is similar in that the task list is setup the same way. This time the user is assigned an automated workflow task as part of the approval workflow. When they try to approve the item in the task list where the item level permission is set to edit access: only their own, a new page opens and displays:

Please wait while your task is updated...

You will be redirected to the previous page after the update is complete.

And then it does this for oh I dont' know... ever. The only way out is to click on the link to the pervious page. I checked the hidden logs for the workflow history and nothing is added to this list indicating that you clicked the Approve button.


I have just discovered SharePoint Designer 2010’s custom task actions and I love them! Unfortunately, there are always things that do your head in. Here’s my problem...

I have a workflow associated with a Forms library that starts three custom task processes, one after another. The final task process has four task form fields, which are Yes/No (check box) site columns. When I edit the task that gets generated, select one of the check boxes, and then click Approve, the task list’s view shows that column with a “No” value instead of the expected "Yes" value.

Here are the details of the custom task action:

From Screen shots

I am the task participant and I am also the task process owner.

I see the columns when I edit the task that gets assigned to me:

From Screen shots

The Tasks list’s view shows the column with the value “No”:

From Screen shots

Am I doing something obviously wrong? The next step in the workflow is to kick off other custom task processes depending on whether these check boxes have been selected.



I have an SQL Azure database that contains LocationLatitude/LocationLongitude fields as floats and a Location field which is of a geography datatype. I want to populate the float fields using EF and the database should automatically update the geography data type through a trigger (both on row inserts and updates).

What's the best way to do that - sample code desperately needed ;-)





Dear All,

My client where i am implementing EPM has some unique requirement

1. First of all client requires that its users will only fill timesheet and through timesheet all of its tasks will be updated according to the hours filled in the timesheet. There should be nothing like Task update and progress and its approval.

2. Cleint requires that it only receives notification for filling timesheet to its users and no notification emails for task updates/ tasks approvals etc.

I tried to search on internet but didn't find something appropriate as per the client requirement. Please reply me urgently.

Thanks and regards,




I have a resource with work hours - 20 hrs for 2.5 d task [task is Fixed Unit, Effort Driven], I want when I update my Resource Actual hours as 10 hrs it may or may not imply that 50% of the work is completed. I don't want to track it through Physical % Complete.

I just want that PM enters Actual Work Hrs & % Complete based on Status not an automated Calculation. 


Hi this is my script.Thers is one query called sqlCmdText in my script task.I just want to take no. of count that will be come by generatring this query and want to assign to a variable.I don't know how can i assign this count to variable and if that variable count >0 then i want to prcoess data flow task and if count<0 then then it will go to next script task in my control flow



Public Class ScriptMain

    Enum ScriptResults
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
    Dim sqlConn As SqlClient.SqlConnection       ' Object to hold connection
    Dim sqlCmd As SqlCommand                     ' SQL Command object

    Dim rdrReader As SqlDataReader               ' Data reader to hold output of command
    Dim sqlCmdText As String                     ' SQL Command text






     Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"
        Public Sub Main()



        sqlConn = DirectCast(Dts.Connections("DestinationConnMgr.ADO.NET").AcquireConnection(Dts.Transaction), SqlClient.SqlConnection)


        sqlCmdText = "select  OPPORTUNITY_ID from GPS.Stg_Batch_Process with (NOLOCK) where GPSToRawCreateDttm >= (select max(dateadd(day,datediff(day, '19000101',CreateDttm),'19000101')) from Stg_Batch_Process)"




Hi i like to count the number of files that get loaded in my foreach task, can some one help me get this setup,




Im using a Script task to extract data from Oracle into SQL Server using SqlBulkCopy. I need to get a count of rows inserted by the SqlBulkCopy and cant figure out how to do this.

I did try the SqlRowsCopied event, but it looks like I need to fill the NotifyAfter property to get the SqlRowsCopied to fire. I am confused because if I have say 11 rows in the source, and set the NotifyAfter to 100 it doesnt fire. If I set the NotifyAfter property to 10, then the event fires and I get the count of 10 and not 11 (however, 11 rows get inserted).

Is there an efficient way to get the RowsCopied for the SqlBulkCopy? 



I have a Multiple File Uploader named "Attachments1" , and to get the cound I used "Attachments1.items.count"... then I have a Insert Into Command for SQL Server, that Inserts information into the table for every item in "Attachments1", you can see the below code...

For Each item As AttachmentItem In Attachments1.Items
            Dim objConn2 As New SqlConnection("Data Source=XXX")
            Dim objCmd2 As New SqlCommand("INSERT INTO clientport (name, event, phone, email, date1, password, path, path2, filename, number)" & "VALUES (@name, @event, @phone, @email, @date1, @password, @path, @path2, @filename, @number)", objConn2)

But for the "number" Column, I would like to insert the Count for that file... For example if Attachments1 has 3 files it will insert into the database the time (which works fine)  the probem is the number column doesnt make file1 for the first file, file 2 for the second file, and file3 for the third file... Instead it puts file3 for all three rows when it Inserts into the DB.  my code is below to get the count.


Dim strcommandtext As String = ""
        For index = 1 To Attachments1.Items.Count Step 1
            strcommandtext += "File" + index.ToString

My current code is like this

Insertinto ReportDetail( Partcipantid, Reportid)

      selectdistinct ParticipantID , 3 from abc  where

        closed = 0 and(isnull( primaryphone, '')


I am trying to accomplish something like this


declare@rec_count  asint

Insertinto ReportDetail( Partcipantid, Reportid)

      (@rec_count=selectdistinct ParticipantID , 3 from abc where

        closed = 0 and(isnull( primaryphone, '')=   )

if @rec_count  = 0 then

Insertinto ReportDetail( Partcipantid, Reportid)

      Values (-1, Reportid)


Is it even possible?

Another less elegant option is to run the same query twice, once to check record count and if it is +ve then run again the same query for insert.

Please advice.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure