0

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 by leo88: n/a

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
0

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 by Mitja Bonca: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.