C#中textbox1中显示数据库中数据时出错
private void button5_Click(object sender, EventArgs e){
string conStr = @"Data Source=于纪东-PC; Initial Catalog = 铝板生产线自动测厚系统数据库;
User ID = sa; Password = sasa;Integrated Security=true";
SqlConnection connection = new SqlConnection(conStr);
SqlCommand cmd = connection.CreateCommand();
= "SELECT 电压,厚度,日期 FROM 数值表";
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
adapter.InsertCommand = cmdBuilder.GetInsertCommand();
adapter.Fill(ds);
DataTable dt = ds.Tables["Table"];
dt.Rows.Add("112.21", "21.12", "2015-05-17 10:21:32");
dt.Rows.Add("115.43", "22.22", "2015-05-17 10:23:12");
dt.Rows.Add("120.12", "23.02", "2015-05-17 10:24:20");
dt.Rows.Add("124.43", "24.52", "2015-05-17 10:27:21");
dt.Rows.Add("113.23", "21.56", "2015-05-17 10:28:20");
dt.Rows.Add("112.34", "21.15", "2015-05-17 10:28:32");
dt.Rows.Add("115.21", "21.98", "2015-05-17 10:29:10");
dt.Rows.Add("109.67", "20.89", "2015-05-17 10:30:12");
dt.Rows.Add("110.23", "21.01", "2015-05-17 10:31:32");
this.textBox1.Text = ds.Tables["电压"].ToString();
this.textBox2.Text = ds.Tables["厚度"].ToString();
this.textBox3.Text = ds.Tables["日期"].ToString();
adapter.Update(ds);
}
}
}