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

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 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

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: A Mid Query

    CodeSOD: A Mid Query

    June 10, 2024

    Many years ago, Tom supported a VB6 application. It was about 750,000 lines of code, split across far too many files, with no real organization to it. While the code was bad and awful, the organization problem was a universal issue for the application. It even infested the database.

    This is some VB6 code for querying that database:

    strSQL = “SELECT * FROM ________ WHERE “ & _
    “project_num = ‘” & rsOpening(“project_num”) & “‘ AND” & _
    “[manf_abbr] = ‘” & rsDoorpodet!manf_abbr & “‘ AND “ & _
    “[series] = ‘” & Mid(rsDoorpodet!SeriesSize, 1, 10) & “‘ AND “ & _
    “[size] = ‘” & Mid(rsDoorpodet!SeriesSize, 11, 28) & “‘ AND “ & _
    “[material_and_gauge] = ‘” & Mid(rsDoorpodet!material_and_gauge_and_finish, 1, 22) & “‘ AND “ & _
    “[finish_and_core] = ‘” & g_current_finish & Mid(rsDoorpodet!core_and_label_and_hand, 1, 20) & “‘ AND “ & _
    “[label_and_machining_code] = ‘” & g_current_label & Mid(rsDoorpodet!machining_code_and_undercut, 1, 30) & “‘ AND “ & _
    “[undercut_and_seamless_and_door_type] = ‘” & g_current_undercut & Mid(rsDoorpodet!SeamlessDoorTypeElevPricegroupPrepgroup,1,11)&“‘AND” & _
    “[ElevPrepGroup] = ‘” & Mid(rsDoorpodet!SeamlessDoorTypeElevPricegroupPrepgroup, 12, 8) & Mid(rsDoorpodet!SeamlessDoorTypeElevPricegroupPrepgroup, 21, 5) & “‘ AND “ & _
    “[WdDrAttrKey] = “ & rsDoorpodet!WdDrAttrKey

    The Hungarian notation tells us that this query is driven by the results of another query- the rs prefix on rsOpening and rsDoorpodet tell us that much. It makes you wonder if maybe this should be a join in the database instead, but then we notice the pile of Mids in the where clause.

    Mid(rsDoorpodet!SeriesSize, 1, 10) and Mid(rsDoorpodet!SeriesSize, 11, 28)- the field SeriesSize holds two values: series and size. I believe “storing data as concatenated fields” is the -1th Normal Form for database normalization. And let’s not miss SeamlessDoorTypeElevPricegroupPrepgroup, which I’m not even sure what all the components in that mean.

    But we even end up getting confused- material_and_gauge_and_finish gets parsed for material_and_gauge, but when we want to populate finish_and_core we get the finish from g_current_finish- a global variable (based on Hungarian notation), and a lovely little SQL injection attack waiting to happen.

    I suspect that this database schema was driven by the tools used to manage this data before there was a database- probably somebody’s Excel spreadsheet. Instead of normalizing the data, they just blindly converted a spreadsheet into an application, and this was the result.

    [Advertisement]
    Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous Article10 VisionOS features I’d like to see Apple announce at WWDC this week
    Next Article From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 17, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2024-47893 – VMware GPU Firmware Memory Disclosure

    May 17, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    T-Mobile users can try Starlink’s satellite service for free – here’s how

    Development

    Building a Realtime Chat App with Vue.js and Laravel

    Development

    Where has Adobe Express been all my Canva-using life?

    News & Updates

    Enhancing Artificial Intelligence Reasoning by Addressing Softmax Limitations in Sharp Decision-Making with Adaptive Temperature Techniques

    Development

    Highlights

    .NET 9 Preview 5 arrives with enhanced AI and faster performance

    June 12, 2024

    Microsoft launched .NET 9 Preview 5, its latest update so far, bringing more AI capabilities…

    Fedora Linux 42: Guida Post Installazione

    April 16, 2025

    Scale write performance on Amazon DocumentDB elastic clusters

    April 16, 2024

    MAINGEAR’s new APEX desktops push the limits of pre-built gaming PCs with custom cooling loops and hidden cables

    January 7, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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