示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var sqlConnectionString  = Properties.Resources.SqlConnectionString;
            var dataTableQueryString = @"SELECT [CustomerID] ,[CompanyName] ,[ContactName] FROM [Customers]";

            var conventionalAdo = new DatabaseThingy.ConventionalAdo();
            var runQueryTable   = conventionalAdo.RunQueryTable(sqlConnectionString, dataTableQueryString);

            foreach (DataRow dataRow in runQueryTable.Rows)
            {
                var displayString = $"ID:{dataRow.Field<string>("CustomerID")},      Customer Name:{dataRow.Field<string>("ContactName")} ";
                lbFileOutput.Items.Add(displayString);
            }
        }
示例#2
0
        public void RunQueryTableTest()
        {
            // Arrange
            var sqlConnectionString  = Properties.Resources.SqlConnectionString;
            var dataTableQueryString = @"SELECT [CustomerID] ,[CompanyName] ,[ContactName] FROM [Customers]";

            // Act
            var conventionalAdo = new DatabaseThingy.ConventionalAdo();
            var runQueryTable   = conventionalAdo.RunQueryTable(sqlConnectionString, dataTableQueryString);

            // Assert
            runQueryTable.ShouldNotBeNull();
            runQueryTable.Columns.Count.ShouldBe(3);
            runQueryTable.Columns[0].ColumnName.ShouldBe("CustomerID");
            runQueryTable.Columns[1].ColumnName.ShouldBe("CompanyName");
            runQueryTable.Columns[2].ColumnName.ShouldBe("ContactName");
            runQueryTable.Rows.Count.ShouldBeGreaterThan(0);
            runQueryTable.Rows[0].ItemArray.Length.ShouldBe(3);
        }