The line array contains the values.And i have to insert the details to database as below, how i change below code to stored procedure
Array linearray = line.Split('|')
string str = "insert into clearing_txn values(";
for (int col = 0; col < linearray.Length; col++)
{
if (col == 1)
{
if (linearray.GetValue(col).ToString().Trim().ToUpper().Equals("VISA"))
{
type = "V";
}
else
{
type = "M";
}
str = str + "'" + type + "',";
}
else if (col == 4)
{
amount = linearray.GetValue(col).ToString().Trim();
amount = amount.Replace(".", "");
if (amount.Length > 2)
{
amount = amount.Substring(0, amount.Length - 2) + "." + amount.Substring(amount.Length - 2, 2);
}
else if (amount.Length == 2)
{
amount = "." + amount;
}
else
{
amount = ".0" + amount;
}
str = str + "'" + amount + "',";
}
else if (col == 5)
{
entity_id = linearray.GetValue(col).ToString().Trim();
for (int i = 0; i < entity_id.Length; i++)
{
if (!entity_id.Substring(i, 1).Equals("0"))
{
entity_id = entity_id.Substring(i, entity_id.Length - i);
i = entity_id.Length;
}
}
str = str + "'" + entity_id + "',";
}
else if (col == 6)
{
if (linearray.GetValue(col).ToString().Trim().ToUpper().Equals("DOM"))
{
txn_type = "D";
}
else
{
txn_type = "I";
}
str = str + "'" + txn_type + "',";
}
else if(col==10)
{
type_card = linearray.GetValue(col).ToString().Trim();
}
else
{
str = str + "'" + linearray.GetValue(col).ToString().Trim() + "',";
}
}
str = str + "'" + outfile + "','" + username + "','N',getdate(),'" + type_card + "')";