I am using Oledbconnection to connect to a Microsoft Access database, and I am using OleDbCommand to retrieve some information. I have a query in the database called retrieveInfo, which retrieves 3 rows of data. There are some duplicates in the fields but that's how it's supposed to be. My data looks like this:
Name Email
A A@gmail.com
B A@gmail.com
B C@gmail.com
My C# code behind looks like this:
DataTable dt = new DataTable();
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
string query = "SELECT * FROM retrieveInfo";
try
{
conn.Open();
DataTable info = new DataTable();
OleDbCommand command = new OleDbCommand(query, conn);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command);
info.Clear();
dataAdapter.Fill(info);
}
I ran the query retrieveInfo in MS Access and it returned 3 rows like shown above. However when I run this command using C# and loaded the data into a datatable, it only shows 2 rows. The datatable only has 1st and 2nd row. I don't know if this has anything to do with the original table properties, or is my C# code wrong? I also tried using a data reader, execute reader and using a while loop to read data. But it also only return 2 rows.
Any help would be appreciated!
Thank you