Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#ASP.NET
how to split string seperated by commas & insert into Sql Database in asp.net c#
Posted 25-May-12 20:31pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this example
 
static void Main()
   {
   string s = "there,is,a,cat";
   //
   // Split string on comma.
   // ... This will separate all the words.
   //
   string[] words = s.Split(',');
   foreach (string word in words)
   {
      //Insert each wrd into database
 //insert(word);

 
   }
   }
  Permalink  
v2
Comments
member60 at 1-Feb-13 6:14am
   
my 5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi ,
Check this
string RValue = "1233,frrrr,rrrryy";
         string[] VExist = RValue.Split(',');
         foreach (string item in VExist)
         {
             using (
               SqlConnection con =
                   new SqlConnection(""))
             {
 

                 using (SqlCommand cmd = new SqlCommand("usp_test", con))
                 {
                     cmd.CommandType = CommandType.StoredProcedure;
                     cmd.Parameters.AddWithValue("@tst", VExist[0]);
                     cmd.Parameters.AddWithValue("@tst2", VExist[1]);
                     cmd.Parameters.AddWithValue("@tst2", VExist[2]);
                     cmd.ExecuteNonQuery();
 
                 }
             }
         }
 
Best Regards
M.Mitwalli
  Permalink  
v2

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 490
1 Shai Vashdi 474
2 Sergey Alexandrovich Kryukov 291
3 OriginalGriff 135
4 praveen_07 115
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,335
2 Peter Leow 4,040
3 Maciej Los 3,540
4 Abhinav S 3,308


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 26 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid