SQL, ASP.NET, and C# Example

This is a compilation of C#, T-SQL/SQL, HTML, and ASP.NET code that I created in my free time and for a project at school. This page has 3 sections:

The Matt Counts System

The scope of the project was to create a custom count/order system for a potential marketing company. This company would have clients who would want output in the form of a zip file that contained two parts:

  • Data file in .csv or .txt (fixed text) format
  • Layout file (txt file)

Within the data file, the typical layout would be:

  • First Name
  • Last Name
  • Address
  • City
  • State
  • 10 digit zip code

The client should have been able to select from one of eight different databases that were pre-generated for us. The database names were:

  • American Family - contained 2 phone fields
  • Grand Timber
  • Little Miracle - contained child birthday field
  • Jefferson - contained child birthday field
  • Ivy - contained email field
  • Nationwide Infomercial - contained email field
  • Blue Haven
  • JG Banks

I pulled all of the tables into a database that I created called "MATT" and created a database called "matt_counts" that would be used to house all of the orders/counts (essentially tables & HTML files) generated by the automated system.

The end result of our project was to be that each student would create a complete automated front-end that allowed for counts and orders to be generated. I took the liberty to create this front end using C#, SQL stored procedures, and ASP.NET.

I finished this project and passed the course with flying colors, I dubbed the project "The Matt Counts System".

Here is the C#/ASP.NET source code:

Matt Counts System

Here are some of the stored procedures that were used in the project:

  • run_counts

    This was a stored procedure that was run by SQL Server once every minute, it checks to see if there are any waiting counts and runs the first one it finds.
  • run_extracts

    This was a stored procedure that was also run by SQL Server once every minute, it checks to see if there are any waiting orders and runs the first one it finds.
  • Ship_out and Add_order

    These stored procedures are used in collaboration with the matt_counts system. Occasionally, there arises times where the automated count system that I created would not be able to complete the request given the situation. In times such as this, custom SQL must be done. However, if we were in the business world, the same type of output would be expected so we would need to accommodate for such a situation. These stored procedures allows for us to take the table generated by the custom SQL created and add it into the automated order system in case we need to use it in the future.

Additional C# Examples

Here are some additional tools that I created to assist me in some of my classes:
  • Get Headers/Flat File Manipulator

    This example takes in a folder containing a bunch of CSV files, and can do one of two things:
    • Grab all of the header information from each of the files and compile it into one CSV file
    • Combine all of the CSV files into one CSV file
    This tool was used to help me import multiple tables into SQL that were originally in CSV format.
  • Matt Tools

    This toolset allows users to do one of two things:
    • Import single CSV files into a SQL table that are in the format of: First Name, Last Name, Address, City, State, Zip code
    • Export tables out of SQL that can be in any format.
  • SQL Link

    This C# code/ DLL allows served as the primary link between a C# front-end web page and SQL tables/database. I compiled this into a DLL so that it could be easily used in the future. Once configured properly, it supports CRUD SQL operations (Create Retrieve Update Delete) and EXEC SQL commands.

Additional SQL Examples

Here are some additional stored procedures:

  • Randometer

    This stored procedure is named randometer because it generates a randomized column that is composed of a date and the reverse last 4 digits of a zip code. Why would we want to do this? This type of procedure would come in handy if we had a client who wanted to generate a count on our existing table, but wanted something nationwide. The columns generated from this procedure would allow us to give our client a nice even spread of individuals or companies if we sorted by them on output.


NOTE: All files here are verified and virus free.