<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Charles Wang's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/changliw/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/changliw/feed.xml</link>
    <description>SQL Server, Cloud Computing, Software Engineering</description>
    <lastBuildDate>Wed, 17 Apr 2019 04:10:42 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SSIS: Dynamically specify folder path for Foreach File Enumerator in Foreach Loop Container</title>
      <link>https://docs.microsoft.com/archive/blogs/changliw/ssis-dynamically-specify-folder-path-for-foreach-file-enumerator-in-foreach-loop-container</link>
      <pubDate>Mon, 19 Jul 2010 03:30:00 GMT</pubDate>
      <dc:creator><![CDATA[SQL Server Forum Support Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/changliw/2010/07/19/ssis-dynamically-specify-folder-path-for-foreach-file-enumerator-in-foreach-loop-container/</guid>
      <description><![CDATA[How do I set folder path dynamically for&nbsp;looping files&nbsp;in a foreach loop container?
Many...]]></description>
      <content:encoded><![CDATA[<p>How do I set folder path dynamically for&nbsp;looping files&nbsp;in a foreach loop container?</p>
<p>Many people may have the question on how to dynamically set the folder path for Foreach File Enumerator in a Foreach Loop Editor. Surprisingly I do not find a blog/article talking about this issue clearly from internet search. So I decide to compose one.</p>
<p>It is quite easy to implement the feature if you know the property Directory of the Foreach File Enumerator. Now let us look at the steps:</p>
<p>1. Create two SSIS variables from the SSIS menu, saying vFileName and vFolderName.</p>
<p>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/36/95/5661.ssisvariables.jpg" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-95/5661.ssisvariables.jpg" border="0" style="max-width: 550px;" /></p>
<p>2. Drag a Foreach Loop Container task to the Control Flow panel, double click it to pop up the property window.</p>
<p>3. Switch to the Collection tab, choose the Enumerator as "Foreach File Enumerator", expand Expressions and add two properties "Directory" for folder path and "FileSpec" for filtering specific types of files. Specify "@[User::vFolderName]" to Directory and "*.txt" to FileSpec.</p>
<p>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/36/95/6281.foreachloopeditor.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-95/6281.foreachloopeditor.png" border="0" style="max-width: 550px;" /></p>
<p>&nbsp;</p>
<p>4. Switch to the Variable Mappings and specify User::vFileName mapping to the index 0.</p>
<p>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/36/95/0876.foreachloopeditor1.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-95/0876.foreachloopeditor1.png" border="0" style="max-width: 550px;" /></p>
<p>&nbsp;</p>
<p>5. Click OK. To show you a sample how it will work, I further add two Script tasks one for pre-setting the folder path while the other output the text files in it.</p>
<p>6. Drag a Script Task into the Control Flow panel, rename it to "Set Folder Path Task", double click the task and specify "User::vFolderName" into the ReadWriteVariables field.</p>
<p>7. Click Edit Script... and add the following code:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Main()</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Add your code here</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dts.Variables["vFolderName"].Value = @"D:\Test\SSIS Foreach Files";</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dts.TaskResult = (int)ScriptResults.Success;</p>
<p>&nbsp;&nbsp;&nbsp; }</p>
<p>8. Connect the script task to the Foreach Loop Container and drag a new Script Task into the container, and rename the new script task as "Output file name task".</p>
<p>9. Double click the "Output file name task", specify "User::vFileName" to the ReadOnly Variables and click the "Edit Script..." button.</p>
<p>10. Add the following code to output the files names: </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Main()</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Add your code here</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool fireAgain = false;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dts.Events.FireInformation(0, "", Dts.Variables["vFileName"].Value.ToString(), "", 0, ref fireAgain);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dts.TaskResult = (int)ScriptResults.Success;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>]]></content:encoded>
    </item>
    <item>
      <title>How do I use ReportViewer 2010 in Visual Studio 2008 project?</title>
      <link>https://docs.microsoft.com/archive/blogs/changliw/how-do-i-use-reportviewer-2010-in-visual-studio-2008-project</link>
      <pubDate>Tue, 29 Jun 2010 00:42:00 GMT</pubDate>
      <dc:creator><![CDATA[SQL Server Forum Support Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/changliw/2010/06/29/how-do-i-use-reportviewer-2010-in-visual-studio-2008-project/</guid>
      <description><![CDATA[&nbsp;
Recently some customers asked me how to use reportviewer 2010 in their visual studio 2008...]]></description>
      <content:encoded><![CDATA[<p><span sizset="0" sizcache="62" style="font-size: small;"><span sizset="0" sizcache="62" style="font-family: trebuchet ms,geneva;"><span sizset="0" sizcache="62" style="font-size: x-small;"></span></span></span><span style="font-family: trebuchet ms,geneva;">&nbsp;</span></p>
<p sizset="0" sizcache="62">Recently some customers asked me how to use reportviewer 2010 in their visual studio 2008 project. <span style="font-family: trebuchet ms,geneva;">ReportViewer 2010 fully supports both Visual Studio 2008 and Visual Studio 2010. The problem is that in Visual Studio 2008, you cannot directly use it in design time. This is a helpful hint, so I decided to dig it out. Really it works very well but need your efforts on extracting the DLLs from GAC and manually coding to create the reportviewer control. Here are my steps to show you how to make it work.</span></p>
<p sizset="0" sizcache="62"><span style="font-family: trebuchet ms,geneva;">1. Download the ReportViewer 2010 Redistributable package from </span><a href="https://www.microsoft.com/downloads/details.aspx?FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd&amp;displaylang=en" style="FONT-FAMILY: "><span style="font-family: trebuchet ms,geneva;">https://www.microsoft.com/downloads/details.aspx?FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd&amp;displaylang=en</span></a><span style="font-family: trebuchet ms,geneva;">. </span></p>
<p sizset="0" sizcache="62" style="FONT-FAMILY: "><span style="font-family: trebuchet ms,geneva;">2. Install it on your computer, then the Microsoft.ReportViewer.WinForm.dll will be registered in GAC, however you could not directly reference this assembly from GAC in Visual Studio 2008. Referencing the assembly file is needed however the dll is not installed in other place. So the next step is how to extract the assembly file from the GAC.</span></p>
<p sizset="0" sizcache="62"><span style="font-family: trebuchet ms,geneva;">3. </span><a href="https://blogs.msdn.com/b/johnwpowell/archive/2009/01/14/how-to-copy-an-assembly-from-the-gac.aspx" style="FONT-FAMILY: "><span style="font-family: trebuchet ms,geneva;">John's blog</span></a><span style="font-family: trebuchet ms,geneva;"> showed some ways to extract assemblies from GAC. I used Windows Command Prompt to extract the Microsoft.ReportViewer.Winform.dll and Microsoft.ReportViewer. Common.dll out to my project's bin folder. You can first use the "cd" command to redirect the folder to " C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms", then use the "dir" command to check which folder is for ReportViewer 10.0 and run "cd" again to redirect to that folder, then run copy command like&nbsp;"copy Microsoft.ReportViewer.Winform.dll D:\Projects\MyTestReport\Bin\Microsoft.ReportViewer.Winform.dll" to copy the file to your project's bin folder. As well you can copy the Microsoft.ReportViewer. Common.dll file.</span></p>
<p sizset="0" sizcache="62" style="FONT-FAMILY: "><span style="font-family: trebuchet ms,geneva;">4. Then in Visual Studio 2008, right click the Reference folder, click "Add Reference...", switch to the Browse tab&nbsp;and add the references to these two assemblies. You can also add the ReportViewer control to the ToolBox via Choose Items by selecting the assembly Microsoft.ReportViewer.Winform.dll in the bin folder, but you will find that the control does not have real UI appearance. It just shows as a component but it is good since you can set properties via the property window.</span></p>
<p sizset="0" sizcache="62" style="FONT-FAMILY: "><span style="font-family: trebuchet ms,geneva;">5. Refer to those auto-generated code for the ReportViewer 2008 control in your project, manually add the code for your Reportviewer 2010 control to your Windows Form application accordingly.</span></p>
<p sizset="0" sizcache="62"><span style="font-family: trebuchet ms,geneva;">6. For example, you have a form named Form1, modify the InitializeComponent function in Form1.Designer.cs as follows.</span></p>
<table cellpadding="0" cellspacing="0" border="1">
<tbody>
<tr>
<td width="590" valign="top">
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;">&nbsp;<span style="font-size: xx-small;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: x-small;">&nbsp;&nbsp; #region Windows Form Designer generated code</span></span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Required method for Designer support - do not modify<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// the contents of this method with the code editor.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void InitializeComponent()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.components = new System.ComponentModel.Container();</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adventureWorksDW2008DataSet = new AdventureWorksDW2008DataSet();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V_GETSALESTableAdapter = new WFMix.AdventureWorksDW2008DataSetTableAdapters.v_getSalesTableAdapter();</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.SuspendLayout();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // reportViewer1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.LocalReport.ReportEmbeddedResource = "WFMix.Report1.rdlc";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.Location = new System.Drawing.Point(13, 13);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.Name = "reportViewer1";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.Size = new System.Drawing.Size(532, 352);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.TabIndex = 0;</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rds.Name = "AdventureWorksDW2008DataSet_v_getSales";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rds.Value = adventureWorksDW2008DataSet.v_getSales;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.LocalReport.DataSources.Add(rds);</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Form1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.ClientSize = new System.Drawing.Size(708, 417);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Controls.Add(this.reportViewer1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Name = "Form1";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Text = "Form1";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Load += new System.EventHandler(this.Form1_Load);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.ResumeLayout(false);</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion</span></span></p>
<p style="FONT-FAMILY: "><span style="font-family: courier new,courier;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Microsoft.Reporting.WinForms.ReportViewer reportViewer1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private AdventureWorksDW2008DataSet adventureWorksDW2008DataSet = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private AdventureWorksDW2008DataSetTableAdapters.v_getSalesTableAdapter V_GETSALESTableAdapter = null;&nbsp;</span></span></p>
</td>
</tr>
</tbody>
</table>
<p><span sizset="0" sizcache="62" style="font-size: small;"><span sizset="0" sizcache="62" style="font-family: trebuchet ms,geneva;"><span sizset="0" sizcache="62" style="font-size: x-small;"></span></span></span><span style="font-family: Trebuchet MS; font-size: x-small;">7. In t</span><span style="font-family: trebuchet ms,geneva;">he Form_Load event, you can fill the data to refresh your report just like ReportViewer 2008.&nbsp;</span></p>
<p sizset="0" sizcache="62">&nbsp;</p>
<table cellpadding="0" cellspacing="0" border="1">
<tbody>
<tr>
<td width="590" valign="top">
<p>&nbsp;<span style="font-family: courier new,courier;">&nbsp;&nbsp;<span style="font-size: xx-small;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: x-small;">&nbsp;private void Form1_Load(object sender, EventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V_GETSALESTableAdapter.Fill(adventureWorksDW2008DataSet.v_getSales);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.reportViewer1.RefreshReport();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
</td>
</tr>
</tbody>
</table>]]></content:encoded>
    </item>
  </channel>
</rss>