Click here to Skip to main content
15,917,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
see the below code:
SqlConnection con = Database.GetConnection();
String column_names = "";
String values = "";
foreach(user_data as key=>value){
column_names = column_names + key+",";
values = values + values+;
}
// remove "," from end of string ..
SqlCommand com = new SqlCommand("insert into members(column_names) values(values)", con);

I want to create this using c#.
Please any one help me....Thanks in advance
Posted
Comments
Ankur\m/ 17-May-11 7:32am    
Is it not C# already? :doh:

1 solution

To remove the final comma in a string you can do something like:

string foo = "a,b,c,d,e,f,".TrimEnd(',');
 
Share this answer
 
Comments
rahul dev123 17-May-11 7:16am    
Not only this but i need how to create column_names string in C#
R. Giskard Reventlov 17-May-11 7:54am    
I'm unclear as to your meaning: please elucidate.

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