|
|
|
Mr 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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 4:11 PM
Points: 1,033,
Visits: 2,593
|
|
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 www.TimMitchell.net twitter.com/Tim_Mitchell
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 4:11 PM
Points: 1,033,
Visits: 2,593
|
|
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 www.TimMitchell.net twitter.com/Tim_Mitchell
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 4:11 PM
Points: 1,033,
Visits: 2,593
|
|
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 www.TimMitchell.net twitter.com/Tim_Mitchell
|
|
|
|