SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Script Task C# Code(The name 'Dts' does not exist in the current context)


Script Task C# Code(The name 'Dts' does not exist in the current context)

Author
Message
zoom19
zoom19
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 302

// C# code
using System;
using System.Data;
using System.IO; // Added
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Runtime;



//[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
string SplitData = Dts.Variables["User::SplitData"].Value.ToString();
public override void CreateNewOutputRows()
{

// Read file (use the FILE connection added in the script component, named myFile)
using (StreamReader sr = new StreamReader(this.Connections.myFILE.ConnectionString, System.Text.Encoding.UTF7)) // Encoding is optional
{
String line;
// Read lines from the file until the end of the file is reached.

if ((line = sr.ReadLine()) != null)
{
if (line.Contains("Clock ID"))
SplitData = "ClockID Data";
else
SplitData = "Employee Clock Data";
}
else
throw new Exception("No data in the file");


}
}



}





I wrote above code in my script task and giving error when I am declare variable.
can you please advice me.I don't know about c# code but I need to use my package to search particular word from .csv file .

thanks in advance....
Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14873 Visits: 14396
SSIS 2005 Script Tasks only support VB.net.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
jm99
jm99
SSC Veteran
SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)

Group: General Forum Members
Points: 200 Visits: 297
Which are you intending to create:

A ScriptTask on the Control Panel or,
A ScriptComponent in a Dataflow?

If a ScriptComponent then the Dts reference is not used to access variables. Specify the variable in the components read-only variable list on the property page then reference it ib C# using the this.Variables collection (similar to how you used this.Connections). The defined variables are returned as typed values eg.

string str = Variables.MyStringSSISVariable;
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39093 Visits: 38518
As opc.three said earlier, you can use any .NET language you want in SSIS 2005 as long as it is VB.NET. C# support was added in SQL Server 2008.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search