//------------------------------------------------------------------------------------------- /// <summary> /// TestDBI_T_affirmation_Write_to_DB -- write itemlist to DB /// </summary> static void TestDBI_T_affirmation_Write_to_DB() { Console.WriteLine(" --START: TestDBI_T_affirmation_Write_to_DB"); affirmation_Table myTable = new affirmation_Table(); myTable.itemList = make_affirmation_list_1(); int iRowsStart = myTable.itemList.Count; myTable.Show(); Util.pause(); Console.WriteLine(" --before clear SQLServer database table"); Util.pause(); myTable.Clear_Database_Table(); int iRows2 = myTable.CountRows(); if (iRows2 != 0) { Util.pause("Error. iRows=" + iRows2 + " should be zero after Clear_Database_Table()"); } else { Util.pause("OK. After Clear_Database_Table()"); } Console.WriteLine("Write the table from RAM the SQLServer Database table"); myTable.WriteItemListToDatabase(); int iRows3 = myTable.CountRows(); if (iRows3 != iRowsStart) { Util.pause("Error. iRows3=" + iRows3 + " should be " + iRowsStart + " after WriteItemListToDatabase"); } else { Util.pause("OK. After WriteItemListToDatabase()"); } Console.WriteLine(" --after writing to the SQLServer database table. examine the table using SSMS"); Util.pause("visually inspect via SSMS?"); Console.WriteLine(" --DONE: TestDBI_T_affirmation_Write_to_DB"); }//TestDBI_T_affirmation_Write_to_DB
static void TestDBI_T_affirmation_Write_Read_T6() { //create demo data: table1 affirmation_Table myTable1 = new affirmation_Table(); myTable1.itemList = make_affirmation_list_1(); int iRows1 = myTable1.itemList.Count; myTable1.Show(); //write to DB myTable1.WriteItemListToDatabase(); //create demo table: table2, read from DB affirmation_Table myTable2 = new affirmation_Table(); int iRows2 = myTable2.itemList.Count; if (iRows1 != iRows2) { Console.WriteLine("Error. row counts don't match"); } else { Console.WriteLine("OK. row countsmatch()"); } //compare table1 & table2 int iResult = CompareLists(myTable1.itemList, myTable2.itemList); if (iResult != 0) { Console.WriteLine("Error. itemLists don't match"); } else { Console.WriteLine("OK. itemLists match"); } Util.pause(); }