Hi, I wants to read data from a datatable, but after I executes the program it does not output anything. Can help me check what is the problem?

string SQLStr; 
            string output="";
            SQLClass Access_Db = new SQLClass();
            AccessDbCmd AccessDb_Cmd = new AccessDbCmd();

            try
            {                
                Access_Db.OpenTransaction();
                Access_Db.BeginTransaction();

                DataTable myTable = new DataTable();

              ScannedPartNoTbl,FautyScanTbl";      
                SQLStr = "SELECT * FROM ScannedPartNoTbl"; 
                myTable = AccessDb_Cmd.RetrieveData(SQLStr, Access_Db).Tables[0];

                string[] array = new string [20];

                int i=0;
                foreach (DataRow row in myTable.Rows)
                {                                       
                    array[i] = (string)row["SerialNo"];                  
                    output += array[i] + "\n";
                    i++;        
                }
                Console.WriteLine(output);  
                                            
            }
            catch (Exception ex)
            {
                //event
            }
            finally
            {
                Access_Db.CloseTransaction();
            }
}

Edited 5 Years Ago by leo88: n/a

Does your DataTable get filled up with data from dataBase?
Use a break point to "stop" the code, and then go with F11 key forward row by row, and with hovering mouse over some value (varible), you will see if there are data inside of it).

Edited 5 Years Ago by Mitja Bonca: n/a

This article has been dead for over six months. Start a new discussion instead.