关于C# 查询 功能的实现代码__教程 |
|
日期:2007-5-15 21:09:11 人气:507 [大 中 小] |
|
|
|
this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.pictureBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "FrmLogin"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "FrmLogin"; ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit(); this.ResumeLayout(false);
} #endregion
private void textBox1_TextChanged(object sender, System.EventArgs e) { }
public void FillDataSet(DataSet2 dataSet21) { //在填充数据集前关闭约束检查 //这允许适配器填充数据集而不用考虑 //表之间的依赖项 dataSet21.EnforceConstraints=false; try { //打开连接 if(this.oleDbConnection1.State!=ConnectionState.Closed) this.oleDbConnection1.Close(); this.oleDbConnection1.Open(); //尝试通过 oleDbDataAdapter1 填充数据集 this.oleDbDataAdapter1.Fill(dataSet21); } catch(Exception fillException) { //在此处添加错误处理代理 MessageBox.Show(fillException.Message); } finally { dataSet21.EnforceConstraints=true; this.oleDbConnection1.Close(); }
} public void LoadDataSet() { //创建一个新数据集以保存从FillDataSet 调用返回的记录. //使用了一个临时数据集,这是因为填充现在的数据集 //需要重新绑定数据绑定 DataSet2 objDataSetTemp=new DataSet2(); try { this.FillDataSet(objDataSetTemp); } catch(Exception eFillDataSet) { MessageBox.Show(eFillDataSet.Message); } try { this.dataSet21.Clear(); |
|
出处:本站原创 作者:佚名 |
|
|