@Edouard Durand , as others said, we could store the time value in Application.settings so that we can check if the app is opened at the first time or at the second time.
First, we could set the following settings in your app.
Second, here is a code example you could refer to.
private void Form1_Load(object sender, EventArgs e)
{
int time = Properties.Settings.Default.Time;
if(time==1)
{
SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=Database1.sqlite");
m_dbConnection.Open();
SQLiteCommand sqlCom = new SQLiteCommand("Select * From highscores", m_dbConnection);
SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCom);
DataSet set = new DataSet();
adapter.Fill(set);
dataGridView1.DataSource=set.Tables[0];
m_dbConnection.Close();
Properties.Settings.Default.Time=time+1;
Properties.Settings.Default.Save();
}
else if(time==2)
{
SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=Database2.sqlite");
m_dbConnection.Open();
SQLiteCommand sqlCom = new SQLiteCommand("Select * From Stuinfo", m_dbConnection);
SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCom);
DataSet set = new DataSet();
adapter.Fill(set);
dataGridView1.DataSource=set.Tables[0];
m_dbConnection.Close();
Properties.Settings.Default.Time=time+1;
Properties.Settings.Default.Save();
}
else
{
MessageBox.Show("You have opened the app 2 times, so you can not open it again");
Properties.Settings.Default.Time=1;
Properties.Settings.Default.Save();
}
}
Finally, you could get the following result:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.