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();
            }
}

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.