Updating Firebird DB every timer's tick in C#
You can call the .ExecuteNonQuery() method. You will probably refactor the name of the command since readCommand
is a little confusing. Then as another suggestion, use parametrized queries, since he code you show is really subject to Query Injection. You ar eusing Firebird, have a look at this example that seems fit exactly your needings.
For the architectural part, I don't know exactly what you have to do, but don't expect the result to be to much time accurate, expect it to be less accurate as shortest is the tick.
An update query uses ExecuteNonQuery not ExecuteReader. No need to build a DataReader when you don't read anything.
Also put a using
statement around the connection (to be certain that the connection will be closed in case of exceptions).
Finally, (and probably the most important advice), use always parameters to work with databases.
private void Timer1_tick(object sender, EventArgs e)
{
using(FbConnection UpdateConnection = new FbConnection(ConnectionString))
{
UpdateConnection.Open();
FbCommand writeCommand = new FbCommand("UPDATE Param SET Test=@myData", UpdateConnection);
writeCommand.Parameters.AddWithValue("@myData", TextBox1.Text);
int recUpdated = writeCommand.ExecuteNonQuery();
}
}