Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Automating Design Systems: Tips And Resources For Getting Started

      August 6, 2025

      OpenAI releases two open weight reasoning models

      August 6, 2025

      Accelerate tool adoption with a developer experimentation framework

      August 6, 2025

      UX Job Interview Helpers

      August 5, 2025

      Yes, you can edit video like a pro on Linux – here are my 4 go-to apps

      August 6, 2025

      I tried Perplexity’s new reservation feature, and it surprised me with new dining spots to try

      August 6, 2025

      Your Samsung TV is getting a huge feature upgrade – 3 AI tools launching right now

      August 6, 2025

      This multi-card reader is one of the best investments I’ve made for my creative workflow

      August 6, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Fluent Object Operations with Laravel’s Enhanced Helper Utilities

      August 6, 2025
      Recent

      Fluent Object Operations with Laravel’s Enhanced Helper Utilities

      August 6, 2025

      Record and Replay Requests With Laravel ChronoTrace

      August 6, 2025

      How to Write Media Queries in Optimizely Configured Commerce (Spire)

      August 6, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Battlefield 6 Developers Confirm AI Bots Will Auto-fill Servers If Player Count Drops

      August 6, 2025
      Recent

      Battlefield 6 Developers Confirm AI Bots Will Auto-fill Servers If Player Count Drops

      August 6, 2025

      Canon imageFORMULA R40 Driver for Windows 11, 10 (Download)

      August 6, 2025

      Microsoft to End Support for Visual Studio 2015 This October

      August 6, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: A Dropped Down DataSet

    CodeSOD: A Dropped Down DataSet

    August 6, 2025

    While I frequently have complaints about over-reliance on Object Relational Mapping tools, they do offer key benefits. For example, mapping each relation in the database to a type in your programming language at least guarantees a bit of type safety in your code. Or, you could be like Nick L‘s predecessor, and write VB code like this.

    For i As Integer = 0 To SQLDataset.Tables(0).Rows.Count - 1
         Try 'Handles DBNull
             Select Case SQLDataset.Tables(0).Rows(i).Item(0)
                 Case "Bently" 'Probes
                     Probes_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "Keyphasor"
                     Keyphasor_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "Transmitter"
                     Transmitter_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "Tachometer"
                     Tachometer_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim.ToUpper.ToString.Trim)
                 Case "Dial Therm"
                     DialThermometer_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "DPS"
                     DPS_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "Pump Bracket"
                     PumpBracket_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "Accelerometer"
                     Accelerometer_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
                 Case "Velometer"
                     Velometer_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim)
             End Select
         Catch
             'MessageBox.Show(text:="Error during SetModelNums().", _
             '                caption:="Error", _
             '                buttons:=MessageBoxButtons.OK, _
             '                icon:=MessageBoxIcon.Error)
         End Try
    Next
    

    So, for starters, they’re using the ADO .Net DataSet object. This is specifically meant to be a disconnected, in-memory model of the database. The idea is that you might run a set of queries, store the results in a DataSet, and interact with the data entirely in memory after that point. The resulting DataSet will model all the tables and constraints you’ve pulled in (or allow you to define your own in memory).

    One of the things that the DataSet tracks is the names of tables. So, the fact that they go and access .Table(0) is a nuisance- they could have used the name of the table. And while that might have been awfully verbose, there’s nothing stopping them from doing DataTable products = SQLDataSet.Tables("Products").

    None of this is what caught Nick’s attention, though. You see, the DataTable in the DataSet will do its best to map database fields to .NET types. So it’s the chain of calls at the end of most every field that caught Nick’s eye:

    SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim
    

    ToUpper works because the field in the database is a string field. Also, it returns a string, so there’s no need to ToString it before trimming. Of course, it’s the Tachometer entry that brings this to its natural absurdity:

    Tachometer_Combobox.Items.Add(SQLDataset.Tables(0).Rows(i).Item(1).ToUpper.ToString.Trim.ToUpper.ToString.Trim)
    

    All of this is wrapped up in an exception handler, not because of the risk of an error connecting to the database (the DataSet is disconnected after all), but because of the risk of null values, as the comment helpfully states.

    We can see that once, this exception handler displayed a message box, but that has since been commented out, presumably because there are a lot of nulls and the number of message boxes the users had to click through were cumbersome. Now, the exception handler doesn’t actually check what kind of exception we get, and just assumes the only thing that could happen was a null value. But that’s not true- someone changed one of the tables to add a column to the front, which meant Item(1) was no longer grabbing the field the code expects, breaking the population of the Pump Bracket combo box. There was no indication that this had happened beyond users asking, “Why are there no pump brackets anymore?”

    [Advertisement] Plan Your .NET 9 Migration with Confidence
    Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleSend Notifications in Laravel with Firebase Cloud Messaging and Notifire
    Next Article Telegraph – Morse translator

    Related Posts

    News & Updates

    Yes, you can edit video like a pro on Linux – here are my 4 go-to apps

    August 6, 2025
    News & Updates

    I tried Perplexity’s new reservation feature, and it surprised me with new dining spots to try

    August 6, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-6452 – CodeAstro Patient Record Management System Cross-Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Get 23% OFF the ‘SteelSeries Arctis Nova Pro Wireless’ headset for Xbox / PC — arguably the best high-end multi-device headset you can get

    News & Updates

    cybercog/laravel-clickhouse

    Development

    CVE-2025-36582 – Dell NetWorker SSL/TLS Algorithm Downgrade Information Disclosure

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    15 Best Free and Open Source Linux Benchmark Tools

    July 25, 2025

    A benchmark is the act of running computer programs in order to assess the performance…

    Build a just-in-time knowledge base with Amazon Bedrock

    July 7, 2025

    CVE-2025-32976 – Quest KACE Systems Management Appliance Two-Factor Authentication Bypass Vulnerability

    June 24, 2025

    CVE-2025-48276 – Visual Composer Cross-site Scripting Vulnerability

    May 19, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.