Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6203041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:50:40+00:00 2026-05-24T04:50:40+00:00

I am currently in a project for college to write a program to store

  • 0

I am currently in a project for college to write a program to store information about other companies they interact with (like contact information, delivery information etc.) and what is in their general stock at any point of time (Such as the Brand, Model, Amount of the item in stock, Manufacturer/Supplier information etc.) and customer information.

I am wondering if I must use a huge amount of stored procedures to take advantage of error handling and transactions using T-SQL, or would it be faster to just use the System.Data.SqlClient.SqlCommand Class to run plain queries? I have some sample code that I have worked out to store information on a customer in a database using T-SQL and C#, which wasn’t a problem. Our task states that we will be judged by complexity and performance of our program.

This is the stored procedure I used:

CREATE PROCEDURE uspAddCustomers @Name varchar(30), @Surname varchar(30), @Addressline1 varchar(300),@Addressline2 varchar(300),@Telephone varchar(12),@CellPhone varchar(12),@Email Varchar(100)
AS
BEGIN TRY
    BEGIN TRANSACTION TrnAddCustomer;
        INSERT INTO [TCTdb].[dbo].[Customers]
                   ([Name]
                   ,[Surname]
                   ,[Addressline1]
                   ,[Addressline2]
                   ,[Telephone]
                   ,[Cellphone]
                   ,[Email])
             VALUES
                   (@Name
                   ,@Surname
                   ,@Addressline1
                   ,@Addressline2
                   ,@Telephone
                   ,@CellPhone
                   ,@Email)
    COMMIT TRANSACTION TrnAddCustomer;
END TRY
BEGIN CATCH
    ROLLBACK TRANSACTION TrnAddCustomer;

    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT 
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

    RAISERROR (@ErrorMessage,
               @ErrorSeverity,
               @ErrorState
               );
END CATCH
GO

These are the Code Snippets I used to call the stored procedure:

private void btnAdd_Click(object sender, EventArgs e)
{
    try
    {
        SQLCommands comm = new SQLCommands(); //Custom Class containing method below.
        comm.AddCustomer(tbName.Text, tbSurname.Text, tbAddressline1.Text, tbAddressline2.Text, tbPhoneNumber.Text, tbCellphoneNumber.Text, tbEmail.Text);
        MessageBox.Show("Success! Note, if the data you inserted was too long, it may have been subjected to truncation to fit in the Database.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        tbName.Text = tbSurname.Text = tbPhoneNumber.Text = tbCellphoneNumber.Text = tbAddressline2.Text = tbAddressline1.Text = tbEmail.Text = string.Empty;
    }
    catch
    {
        MessageBox.Show("It appears something has gone wrong. Please contact the Supervisor if this problem keeps reoccurring", "Unknown Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
}

AND

 public void AddCustomer(params string[] parameters)
    {
        try
        {
            comm = new SqlCommand("UspAddCustomers", conn); // Stored Procedure
            comm.Parameters.AddWithValue("@Name", parameters[0]);
            comm.Parameters.AddWithValue("@Surname", parameters[1]);
            comm.Parameters.AddWithValue("@Addressline1", parameters[2]);
            comm.Parameters.AddWithValue("@Addressline2", parameters[3]);
            comm.Parameters.AddWithValue("@Telephone", parameters[4]);
            comm.Parameters.AddWithValue("@CellPhone", parameters[5]);
            comm.Parameters.AddWithValue("@Email", parameters[6]);
            comm.CommandType = CommandType.StoredProcedure;
            comm.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
        }
    }

The Question:
So to revise my question, I was about to use this type of code to handle all CRUD for my tables in my database. I am worried though that this may chew the performance of my program, because there is a lot of tables involved. Is it advisable to carry on like this, or should I consider using simpler methods for manipulating data in my database?

The reason why I thought of using this method was to enhance complexity

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:50:42+00:00Added an answer on May 24, 2026 at 4:50 am

    Since you are using C#, have you considered using LINQ-to-SQL? It’s a pretty sophisticated framework built into .NET, but very easy to use and eliminates the need for a good deal of framework code in the lower levels of your code. It could save you a good deal of time, but maybe only if you have time to familiarize yourself with LINQ-to-SQL. I have used it in an environment where we don’t use stored procedures (the queries and updates are effectively generated by LINQ-to-SQL based on LINQ queries and methods written in the code), but I believe you can also tell it to use stored procedures.

    I’m not sure how they’re scoring complexity. If it’s based on how much code you write, then this might be a step in the wrong direction, since I think you would write much less code. But overall, I think more complexity/sophistication would be involved in a LINQ-to-SQL solution because it translates LINQ queries into SQL queries internally, and can be ported to other database platforms as a result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently attempting to code one for part of a college project - binary/hex
I'm currently building a project and I would like to make use of some
I am currently working on a simple Scrabble implementation for a college project. I
I currently have basic knowledge of C++ and VB.Net. For our college project i
Currently doing a group project for college in Java. The assignment is to produce
I'm currently working on a group project for a college course, and I've hit
I am currently working on one of my college project which requires the implementation
I am currently using GitHub for a project with my college professor. Since I
I'm currently working on a Doubly Linked List project in my college java course.
The project currently I am working in requires a lot of searhing/filtering pages. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.