Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Using the Script Component With Multiple Outputs Expand / Collapse
Author
Message
Posted Wednesday, November 17, 2010 12:36 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, December 26, 2012 11:03 PM
Points: 586, Visits: 2,195
Hi,

I just copy and past but getting error


public override void CreateNewOutputRows()
{
// Create the StreamReader object to read the input file
System.IO.StreamReader reader = new System.IO.StreamReader(this.Variables.Filename);

// Loop through the file to read each line
while(!reader.EndOfStream)
{
// Read one line
string line = reader.ReadLine();

// Break the file apart into atomic elements
string[] items = line.Split('|');

// Record type 1 is Manager
if (items[0] == "1")
{
ManagerOutputBuffer.AddRow();
ManagerOutputBuffer.ManagerID = int.Parse(items[1]);
ManagerOutputBuffer.ManagerName = items[2];
ManagerOutputBuffer.ManagerRole = items[3];
ManagerOutputBuffer.Location = items[4];
}

// Record type 2 is Employee
elseif (items[0] == "2")
{
EmployeeOutputBuffer.AddRow();
EmployeeOutputBuffer.EmployeeID = int.Parse(items[1]);
EmployeeOutputBuffer.ManagerID = int.Parse(items[2]);
EmployeeOutputBuffer.EmployeeName = items[3];
EmployeeOutputBuffer.EmployeeRole = items[4];
}

// Record type 3 is Client
elseif (items[0] == "3")
{
ClientOutputBuffer.AddRow();
ClientOutputBuffer.SalespersonID = int.Parse(items[1]);
ClientOutputBuffer.ClientID = int.Parse(items[2]);
ClientOutputBuffer.ClientName = items[3];
}
}
}

I am getting this error what that it means did i miss some thing refer screenshot

Thanks
Parthi


Thanks
Parthi


  Post Attachments 
error.JPG (2 views, 127.14 KB)
Post #1022403
Posted Thursday, December 2, 2010 8:23 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 5:32 PM
Points: 1,045, Visits: 2,722
dpatel0501-696442 (5/21/2009)
So whats the right approach when we have records in the header as opposed to not having them in details?


If I read your question right, you're asking how to address the headers in a file? I haven't run across one of these multi-format files that had a header, because a single header can't describe the various metadata. Perhaps a file could have headers within the data - I haven't seen this approach, but if this exists you'd need to use your script to detect the header records (the method for which would vary depending on the makeup of the header) and either discard the headers or use them to identify the upcoming metadata.

hth,
Tim




Tim Mitchell, SQL Server MVP
Independent Business Intelligence Consultant
www.TimMitchell.net
@Tim_Mitchell

Post #1029616
Posted Thursday, December 2, 2010 8:24 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 5:32 PM
Points: 1,045, Visits: 2,722
psripuram (8/5/2010)
Can I have the same example shown in VB please


Unfortunately I don't have a VB example for this code - most of my sample scripts are in C#.




Tim Mitchell, SQL Server MVP
Independent Business Intelligence Consultant
www.TimMitchell.net
@Tim_Mitchell

Post #1029617
Posted Thursday, December 2, 2010 8:31 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 5:32 PM
Points: 1,045, Visits: 2,722
parthi-1705 (11/17/2010)
Hi, I just copy and past but getting error


It looks like there are a couple of errors. First of all, the
elseif

should be
else if

. It looks like the browser causes those to run together for some reason.

The highlighted error indicates that you don't have a variable named
Filename

in this scope. You'll want to create a variable with this name in your package, which should be populated with the name of the file you want to shred.

hth,
Tim




Tim Mitchell, SQL Server MVP
Independent Business Intelligence Consultant
www.TimMitchell.net
@Tim_Mitchell

Post #1029619
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse