将数据集值存储在数据库中 [英] Storing dataset values in a database

查看:140
本文介绍了将数据集值存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我已经分割了我的数据集值,现在我需要将它存储在数据库中,这是一个有用的想法,这是我的编码提取数据集

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

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());
              
            }
        }

推荐答案

您能解释一下您的要求吗?因此,我们可以尝试为您提供正确的解决方案。



您可以通过为表创建一个类来实现您的方法,并将数据集对象存储在此这个班级的名单。操纵它然后你就可以执行关于表中每个对象的更新命令。





如果它解决了,请标记为答案您的问题。
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.


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());
            }


这篇关于将数据集值存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆