Click here to Skip to main content
16,017,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have wrote a method which get's parameter of Class , and Stored procedure name
C#
Cmd.Parameters.Add("@C_Id", SqlDbType.Int).Value = UI.C_Id;
Cmd.Parameters.Add("@C_Name", SqlDbType.VarChar, 30).Value = UI.C_Name;


i used as @C_Id as Odd Code , but i want to pass as argument

pls give Suggestion

Thanks,
Posted
Updated 30-Jul-12 21:53pm
v2
Comments
Christian Graus 31-Jul-12 3:53am    
I can't work out what you want. Where is the dictionary in all this ?

1 solution

You want to save often used Strings. You have several Approaches. My Preferred Approach is adding a constants.cs with static string:

C#
internal class Constants 
{
  internal static String Id = "@C_Id";
}


you can use it later by calling

C#
Cmd.Parameters.Add(Constants.Id, SqlDbType.Int).Value = UI.C_Id;


Another Approach is using an enum with the ToString() Method. A Dictionary is not the best way, since it always has to be initialized first.

Hope i could help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900