I have a question regarding the SQLite Database connection.
I habe a code like that:
using (SQLiteConnection connection = new SQLiteConnection("Data Source= " + dataSource))
{
connection.Open();
using (SQLiteCommand command = connection.CreateCommand())
{
command.CommandText = "SELECT MAX(X_AXIS) FROM GraphCoor_" + EnvironmentalValue + ";";
try
{
using (SQLiteDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
MAX = Convert.ToInt32(reader[0]);
}//END_while
}//END_using reader
}
}//END_using command
}//END_using connection
I have several functions where I use the code with the creation of the SQLiteConnection and the connection.open command. My question is, would it be better to create and open the connection once?
Aucun commentaire:
Enregistrer un commentaire