I have this code to transfer records from one-table to the other
cmd2.CommandText = "select * from " + TableName;
reader = cmd2.ExecuteReader();
if (reader != null)
{
String s = "".PadLeft(reader.FieldCount - 1, 'X').Replace("X", "?,") + "?";
cmd.CommandText = String.Format("{0} into {1} values ({2})", insertorreplace, TableName, s);
StringBuilder sb = new StringBuilder();
while (reader.Read())
{
int i = 0;
for (i = 0; i < reader.FieldCount; ++i)
{
cmd.Parameters.AddWithValue(null,reader[i].ToString()); // data type issue
}
cmd.ExecuteNonQuery();
}
reader.Close();
}
Probably because of the commented line I get data type issue. I want all things to be passed by string.
Still looking for answers