Ram Prasad

Ram Prasad

  • NA
  • 326
  • 18.2k

Comparing output of program with the sqlite database

Jan 27 2021 6:06 AM
I am comparing dataVal output with the sqlite database as shown in the code below.
For Example: Lets assume output of dataVal is Kelly. When I run the program, in the first loop string z stores value "K" and then store "Kelly" only after second loop. Can someone please elaborate what is happening here and how to get the value of z as 'Kelly' after first loop?
 
dataVal = string.Join("", dataResult.ToArray());
Aryabase databaseObject = new Aryabase();
if (dataVal.StartsWith('k'))
{
using (SQLiteConnection con = new SQLiteConnection(databaseObject.myConnection))
{
SQLiteCommand cmd = new SQLiteCommand("select * from k where Data like 'k%'", con);
con.Open();
var rdr = cmd.ExecuteReader();
while (rdr.Read())
{
string z = Convert.ToString(rdr["Data"]);
if (dataVal == z)
{
Console.WriteLine(Convert.ToString(rdr["Data"]));
}
}
}
}

Answers (1)