I am trying to test this script. I am unable to get past the2nd line
- VariableDispenser.LockForRead(“User::filename”);.
I get the error
-
System.Runtime.InteropServices.COMException: ‘The variable cannot be found.
public override void CreateNewOutputRows()
{
IDTSVariables100 vars = null;
VariableDispenser.LockForRead(“User::filename”);
VariableDispenser.LockForRead(“User::cycle”);
VariableDispenser.LockForRead(“User::inputfileid”);VariableDispenser.GetVariables(out vars);
string InputFile = vars[“User::filename”].Value.ToString();
string Cycle = vars[“User::cycle”].Value.ToString();
int InputFileID = (int)vars[“User::inputfileid”].Value;
vars.Unlock();// Create the StreamReader object to read the input file
System.IO.StreamReader reader =
new System.IO.StreamReader(Path.Combine(InputFile,Cycle,”details.txt”));// Loop through the file to read each line
while (!reader.EndOfStream)
{
// Read one line
string line = reader.ReadLine();AutoPayTempBuffer.AddRow(); AutoPayTempBuffer.cycle = Cycle; AutoPayTempBuffer.inputfileid = InputFileID; AutoPayTempBuffer.source = line.Substring(0, 2).Trim(); AutoPayTempBuffer.lettercode = line.Substring(2, 8).Trim(); AutoPayTempBuffer.accountnumber = line.Substring(10, 13).Trim(); AutoPayTempBuffer.address = line.Substring(82, 40).Trim(); AutoPayTempBuffer.city = line.Substring(122, 28).Trim(); AutoPayTempBuffer.state = line.Substring(150, 2).Trim(); AutoPayTempBuffer.country = line.Substring(152, 6).Trim(); AutoPayTempBuffer.zip = line.Substring(158, 10).Trim(); AutoPayTempBuffer.branch = line.Substring(168, 5).Trim(); AutoPayTempBuffer.branchname = line.Substring(173, 40).Trim(); AutoPayTempBuffer.branchaddress = line.Substring(213, 40).Trim(); AutoPayTempBuffer.branchcity = line.Substring(253, 28).Trim(); AutoPayTempBuffer.branchstate = line.Substring(281, 2).Trim(); AutoPayTempBuffer.branchzip = line.Substring(283, 10).Trim(); AutoPayTempBuffer.branchphone = line.Substring(293, 12).Trim(); AutoPayTempBuffer.remitname = line.Substring(305, 40).Trim(); AutoPayTempBuffer.remitaddress = line.Substring(345, 40).Trim(); AutoPayTempBuffer.remitcity = line.Substring(385, 28).Trim(); AutoPayTempBuffer.remitstate = line.Substring(41, 2).Trim(); AutoPayTempBuffer.remitzip = line.Substring(415, 10).Trim(); AutoPayTempBuffer.remitphone = line.Substring(425, 12).Trim(); AutoPayTempBuffer.vehicleyear = line.Substring(437, 4).Trim(); AutoPayTempBuffer.vehiclemake = line.Substring(441, 15).Trim(); AutoPayTempBuffer.vehiclemodel = line.Substring(456, 20).Trim(); AutoPayTempBuffer.vin = line.Substring(476, 17).Trim(); AutoPayTempBuffer.dealercode = line.Substring(493, 6).Trim(); String tempString = line.Substring(499, 8).Trim(); if (!String.IsNullOrEmpty(tempString)) AutoPayTempBuffer.paymentdate = DateTime.ParseExact(tempString, "MMddyyyy", CultureInfo.InvariantCulture); AutoPayTempBuffer.paymentday = line.Substring(507, 2).Trim(); AutoPayTempBuffer.paymentamount = line.Substring(509, 15).Trim(); AutoPayTempBuffer.bankaccountnumber = line.Substring(524, 19).Trim(); tempString = line.Substring(499, 8).Trim(); if (!String.IsNullOrEmpty(tempString)) AutoPayTempBuffer.accountdate = DateTime.ParseExact(tempString, "MMddyyyy", CultureInfo.InvariantCulture); AutoPayTempBuffer.specialletterindicator = line.Substring(551, 1).Trim(); tempString = line.Substring(552, 8).Trim(); if (!String.IsNullOrEmpty(tempString)) AutoPayTempBuffer.currentmaturitydate = DateTime.ParseExact(tempString, "MMddyyyy", CultureInfo.InvariantCulture); tempString = line.Substring(560, 8).Trim(); if (!String.IsNullOrEmpty(tempString)) AutoPayTempBuffer.contractmaturitydate = DateTime.ParseExact(tempString, "MMddyyyy", CultureInfo.InvariantCulture); AutoPayTempBuffer.languageindicator = line.Substring(568, 1).Trim(); AutoPayTempBuffer.address2 = line.Substring(569, 40).Trim(); AutoPayTempBuffer.name = line.Substring(609, 50).Trim(); AutoPayTempBuffer.businessflag = line.Substring(659, 1).Trim();
}
}
Rebeca Lackey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.