将日期从txt插入数据库c#

时间:2018-04-19 13:09:21

标签: c#

DataTable dt = new DataTable();
private void Form1_Load(object sender, EventArgs e)
{
    dt.Columns.Add("X");
    dt.Columns.Add("Y");
    this.dataGridView1.DataSource = dt;
}
private void button1_Click(object sender, EventArgs e)
{
    dt.Columns.Add("Z").SetOrdinal(0);
}

为什么我不能逐字逐句地获取文字而且我得到char的char ...? 我有这个文本

StreamReader sr = new StreamReader("planificari.txt");
        string linie;
        while ((linie = sr.ReadLine()) != null)
        {
            char[] restr = { '*' };
            string[] txt = linie.Split(restr);
            foreach (var ser in txt) 
            {
                while (i < linie.Length-1)
                {
                    string ins = "insert into Planificari(Localitate,Frecventa,DataStart,DataStop,caleFisier)values('"+ser[i]+"','"+ser[i+1]+"','"+ser[i+2]+"','"+ser[i+3]+"','"+ser[i+4]+"')";
                    MessageBox.Show(ins);
                    SqlCommand cmd = new SqlCommand(ins, con);
                    cmd.ExecuteNonQuery();
                    SqlDataAdapter sda = new SqlDataAdapter(cmd);
                }
            }

我只得到这个https://imgur.com/a/lQFizQQ

0 个答案:

没有答案