日期:2014-05-18 浏览次数:20522 次
private SqlDataAdapter sqlAdapter; private DataSet dataSet; private SqlConnection sqlConn = new SqlConnection("Server=.;uid=sa;pwd=1234;database=TDMSdataBase"); private void AddPoints_Load(object sender, EventArgs e) { //查询数据库用的SQL语句 string sqlCmd = "SELECT * FROM LearnedPointTable"; // 创建数据集对象 sqlAdapter = new SqlDataAdapter(sqlCmd, sqlConn); // 创建数据集对象 dataSet = new DataSet("TDMSdataBase"); // 填充数据集 sqlAdapter.Fill(dataSet, "LearnedPointTable"); LearnedPoints.DataSource = dataSet.Tables["LearnedPointTable"]; LearnedPoints.Columns["PointID"].Visible = false; LearnedPoints.Columns["PointName"].HeaderText = "点名"; LearnedPoints.Columns["PointName"].ReadOnly = false; LearnedPoints.Columns["HorizontalAngle"].HeaderText = "水平角"; LearnedPoints.Columns["HorizontalAngle"].ReadOnly = true; sqlConn.Close(); }
datatable中添加数据,就碰到GUID无法添加的问题了--> GUID用GUID.NewGuid().ToString()