9
Answers

Data Validation Procedure in C#

Ask a question
Hi guys,
 
I hope you can help me. i am quite new to C# development, and would really appreciate your expertise.
 
I want a simple procedure/function I can call to validate the data in a table: 
 
So this is what needs to happen:
  1. Procedure that loops through the Staging Table
  2. Update certain fields based on some rules
Here are some examples of the rules to apply based upon the value of the specific field in the table:
  1. 1. if [Data].[Finance_Project_Number] = Null/Blank

    · Set [Processing_Result] = 2

    · set [Processing_Result_Text] = “No Project Number”

    2. if [Data].[Finance_Project_Region] = Null/Blank

    · Set [Processing_Result] = 2

    · set [Processing_Result_Text] = “No Region”

    Also, on point no 2, how can I check for valid entries? Something like “one of”: Gauteng, Free State, Limpopo etc. If it is “one of” then it passes, otherwise;

    · Set [Processing_Result] = 2

    · set [Processing_Result_Text] = “Incorrect Region Entered”

    3. Cross reference the customer number with another table.column: [Data].[Customer_Number] exists in [CustomerMaster].[Customer_Code]

    if not:

    · Set [Processing_Result] = 2

    · set [Processing_Result_Text] = “Customer Number does not Exist”

I thank you in advance!

Answers (9)