Skip to content

Instantly share code, notes, and snippets.

@ivanbuzyka
Created September 25, 2014 07:48
Show Gist options
  • Save ivanbuzyka/de68b545fdd43e9068ad to your computer and use it in GitHub Desktop.
Save ivanbuzyka/de68b545fdd43e9068ad to your computer and use it in GitHub Desktop.
// Converting Form table
this.PopulateMessage("MIGRATION START: Converting Form table", this.resultDiv);
var values = new object[6];
var command = new SQLiteCommand("SELECT * FROM Form", sqliteConnection);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
reader.GetValues(values);
using (var commandSql = new SqlCommand("INSERT INTO Form(StorageName, Data, FormItemId, Id, SessionId, Timestamp) VALUES(@StorageName, @Data, @FormItemId, @Id, @SessionId, @Timestamp)", sqlConnection))
{
commandSql.Parameters.Add(new SqlParameter("@StorageName", values[0]));
commandSql.Parameters.Add(new SqlParameter("@Data", values[1]));
commandSql.Parameters.Add(new SqlParameter("@FormItemId", values[2]));
commandSql.Parameters.Add(new SqlParameter("@Id", values[3]));
commandSql.Parameters.Add(new SqlParameter("@SessionId", values[4]));
commandSql.Parameters.Add(new SqlParameter("@Timestamp", values[5]));
this.PopulateQueryMessage(commandSql.CommandText);
commandSql.ExecuteNonQuery();
}
}
this.PopulateMessage("MIGRATION SUCCESS: Converting Form table", this.resultDiv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment