Hi just a quick question for my own curiosity. I am trying to not repeat my code. Im still learning how to use parameters and arguments properly so i would imagine it will be through this route here is my code.
public void MultiChoiceLight()
{
lCon = new SQLiteConnection(@"Data Source=knowledge.db;Version=3");
lCon.Open();
string query1 = $"UPDATE testOrder SET question='{QuestionsFromDb.question}', choice1='{QuestionsFromDb.choice1}" +
$"', choice2='{QuestionsFromDb.choice2}', choice3='{QuestionsFromDb.choice3}', choice4='{QuestionsFromDb.choice4}' " +
$"WHERE qid={QuestionsFromDb.b}";
lCmd = new SQLiteCommand(query1, lCon);
lCmd.ExecuteNonQuery();
lDr = lCmd.ExecuteReader();
lCon.Close();
}
public void MultiChoiceButtonNext()
{
lCon = new SQLiteConnection(@"Data Source=knowledge.db;Version=3");
lCon.Open();
string query = $"SELECT * FROM testOrder WHERE qid={qid}";
lCmd = new SQLiteCommand(query, lCon);
lCmd.ExecuteNonQuery();
lDr = lCmd.ExecuteReader();
}
Ok so what im trying to figure out is to use the lines of code within each method only once and then input the query in afterwards so i can do this as many times as possible via a method. I have quite a few methods like this and would really like to shorten my code. Before you say i am aware of lambda expressions and entity but im not using it within the application i am trying to make. Would be nice if i could save my queries into a class file then call them from there just to make my code look tidy. Thanks for reading.