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