Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have split my dataset values and now i need to store that in database am nt geting idea do Me a favour pls and here is my coding for extracting the dataset
C#
public void spilt()
        {
            ///////// DATA SPILT IN TXT FILE ////////////
            try
            {
                String path = textBox1.Text;
                StreamReader file = new StreamReader(path);
                string myString = file.ReadToEnd();
                string[] words = myString.Split('\n');
                for (int x1 = 0; x1 < words.Length - 1; x1++)
                {
                                        data = words[x1].Split(' ', '\r');
                  
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
              
            }
        }
Posted
Comments
Sushil Mate 10-Jul-13 0:54am    
What's data? string array? how about database, tell us the about table schema?
usha C 10-Jul-13 1:01am    
the database table contain of 6 columns...i have splited those datas and now i need to store that in a database
Naz_Firdouse 10-Jul-13 1:06am    
what does the data contains in your app???
YOu specified as "DATA SPILT IN TXT FILE " and also mentioned "I have split my dataset values " ...please elaborate your question...

Could you please explain your requirement? So that we can try to provide you the correct solution.

For while you can achieve your approach by creating a class for your table and store the dataset objects in this this list of this class. manipulate it and then you be able to perform the update command regarding each object in to the table.


Mark as answer if its solved your issue.
 
Share this answer
 
C#
try
            {
          
                String data1 = data[1];
                String data2 = data[2];
                String data3 = data[3];
                String data4=data[4];
                String data5 = data[5];
                String data6=data[6];
              cmd = new SqlCommand("Insert into Datasetextraction values('" + data1 + "','" + data2 + "','" + data3 + "','" + data4 + "','"+data5+"','"+data6+"')",cn.con);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
 
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