Beispiel #1
0
        public void TestUpdate()
        {
            ISqlCommand cmd = new CodingCat.MsSqlTeaser.SqlCommand()
                              .AppendCommand("Select TOP 100 * From tblTest ")
                              .AppendCommand("Where PK = @id ");

            cmd.AddParameter("@id", 5);
            IDbTable DataTable = null;

            using (IDbConnector DbConnector = new CodingCat.MsSqlTeaser.DbConnector(
                       this.ConnectionString
                       ).Read(cmd, out DataTable))
            {
                if (DataTable != null && DataTable.Rows.Count > 0)
                {
                    DataTable.FirstRow
                    .AttachValue("TextField", "TestTextField2")
                    .AttachValue("NVarcharField", "TestNVarcharField2")
                    .AttachValue("DateTimeField", System.DateTime.Now);
                    DbConnector.Update(DataTable);

                    System.Diagnostics.Debug.WriteLine(
                        "LatestID: {0}, Affected: {1}", DbConnector.LatestID, DbConnector.AffectedRowCount
                        );
                }
            }
        }
Beispiel #2
0
        public void TestDelete()
        {
            ISqlCommand cmd = new CodingCat.MsSqlTeaser.SqlCommand()
                              .AppendCommand("Delete From tblTest Where PK = @id ");

            cmd.AddParameter("@id", 5);
            using (IDbConnector DbConnector = new CodingCat.MsSqlTeaser.DbConnector(this.ConnectionString).Delete(cmd))
                System.Diagnostics.Debug.WriteLine(
                    "LatestID: {0}, Affected: {1}", DbConnector.LatestID, DbConnector.AffectedRowCount
                    );
        }