DataRelations.Add
来源:互联网 发布:linux创建新用户和密码 编辑:程序博客网 时间:2024/06/08 08:17
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DataRelation
{
public partial class frmDataSet : Form
{
public frmDataSet()
{
InitializeComponent();
}
private void frmDataSet_Load(object sender, EventArgs e)
{
SqlConnection conn=null ;
string m_sConnStr = "server=(local);Data Source='WWW-F91E7F59A2C';Initial Catalog='SuperMarket';Integrated Security='True'";
conn = new SqlConnection(m_sConnStr);
conn.Open();
string mysql = "select*from Type";
SqlCommand cmd = new SqlCommand(mysql ,conn );
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
cmd.ExecuteNonQuery();
DataSet ds = new DataSet();
da.Fill(ds,"Type");
BindingSource parentBindingSourse = new BindingSource(); //parentBindingSourse type
parentBindingSourse.DataMember = "Type";
parentBindingSourse.DataSource = ds.Tables["Type"];
string mysql2 = "select 编号,名称,产地,进价,类型编号 from product";
SqlCommand cmd2 = new SqlCommand(mysql2 ,conn);
cmd2.CommandType = CommandType.Text;
SqlDataAdapter da2 = new SqlDataAdapter();
da2.SelectCommand = cmd2;
cmd2.ExecuteNonQuery();
da2.Fill(ds, "Product");
DataColumn parentColumn = new DataColumn();
parentColumn = ds.Tables["Type"].Columns ["编号"];
DataColumn childColumn = new DataColumn();
childColumn = ds.Tables["Product"].Columns["类型编号"];
ds.Relations.Add("TypeProduct", ds.Tables["Type"].Columns["编号"], ds.Tables["Product"].Columns["类型编号"], false);
BindingSource childBingSourse = new BindingSource(); //childBingSourse
childBingSourse.DataMember = "TypeProduct";
childBingSourse.DataSource = parentBindingSourse;
dgvParent.DataSource = parentBindingSourse;
dgvChild.DataSource =childBingSourse;
conn.Close();
}
}
}
- DataRelations.Add
- add
- add
- add
- add
- ADD
- add
- adD
- add
- add
- Add.html Add.php
- Attributes.add
- add-in
- Attributes.Add
- Droppables.add
- add oil
- ADD-CORRESPONDING
- chkconfig --add
- 新人来了
- 效率的思考
- 随机函数终于能用了
- 第一次发表笔记。。。嗯哪。。。为了积分。。以后会好好写的
- 相信在这里会找到自己需要的……
- DataRelations.Add
- SQL简单实践之sql语句
- nice ,every one
- 今天的我
- C到C++
- 函数传出参数,用指针作为函数的传出参数实现多值返回
- 黎明之前
- 路由协议
- NAT的类型