Um...There are a few things wrong there.
The one you have noticed is simple:
for i=1;i<100;i++)
{
string sql2 = "UNION ALL SELECT tile = tile[i+1];
string sql = sql1+sql2;
}
Will always exist with the same string, because each time round the loop you overwrite the previous content of
sql
and
sql2
instead of adding to them.
Probably, what you want is closer to:
for i=1;i<100;i++)
{
string sql2 = "UNION ALL SELECT tile = tile[i+1];
string sql1 += sql2;
}
sql += sql1;
But that won't work either because:
1) You are missing the end double quote!
2) You need a space to separate the UNION parts:
for i=1;i<100;i++)
{
string sql2 = " UNION ALL SELECT tile = tile[i+1]";
string sql1 += sql2;
}
sql += sql1;
1) you need a number not a string:
for i=1;i<100;i++)
{
string sql2 = string.Format(" UNION ALL SELECT tile = tile[{0}]", i + 1);
string sql1 += sql2;
}
sql += sql1;
But if you are going to do things like that, I'd strongly suggest you start looking at using a StringBuilder instead of string concatenation!