Thulasiram pakala

Thulasiram pakala

  • 912
  • 872
  • 115.4k

unreachable code detected

Feb 13 2019 1:08 AM
HI
I am Using this code 
public Boolean insert(DataSet ds)
{
for (int i = 0; i < ds.Tables.Count; i++)
{
SqlCommand cmd = new SqlCommand();
string values = string.Empty;
for (int j = 0; j < ds.Tables[i].Rows.Count; j++)
{
values += "insert into " + ds.Tables[i].TableName + " values(";
for (int k = 0; k < ds.Tables[i].Columns.Count; k++)
{
if (ChkSqlinjection(ds.Tables[i].Rows[j][k].ToString()))
{
values += ")\n";
break;
}
else
{
if (ds.Tables[i].Columns[k].DataType != typeof(int))
{
if (ds.Tables[i].Rows[j][k].ToString().Contains("'"))
{
ds.Tables[i].Rows[j][k] = ds.Tables[i].Rows[j][k].ToString().Replace("'", "''");
}
if (ds.Tables[i].Rows[j][k].ToString().Length == 0)
{
values += "NULL";
}
else
{
values += "'" + ds.Tables[i].Rows[j][k] + "'";
}
}
else
{
values += ds.Tables[i].Rows[j][k];
}
if (k < ds.Tables[i].Columns.Count - 1)
{
values += ",";
}
else
{
values += ")\n";
}
}
}
}
using (TransactionScope tr = new TransactionScope())
{
cmd.Parameters.Add("@qry", SqlDbType.VarChar).Value = values;
check(ds.Tables[i].Rows[0], ds.Tables[i].Rows[ds.Tables[i].Rows.Count - 1]);
insertRecord(cmd, ds.Tables[i].TableName);
tr.Complete();
return true;
}
}
return false;
}
 
Analyse source code time i got error in unreachable error code what wrong n this code please correcr it and sent it 
 

Answers (5)