Hey Guys,
I have a question...
I want to display data from two different tables into a single datagrid view.
Problem is i dnt wana join the tables. pls check this code
private void bindgrid()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str1 = "Select * from wcl_et ";
str2 = "Select * from secl_et";
str3 = "select * from sccl_et";
ad = new SqlDataAdapter(str1, con);
ad.Fill(ds1, "wcl_et");
ad = new SqlDataAdapter(str2, con);
ad.Fill(ds2, "secl_et");
//ds1.Merge(ds2);
dataGridView1.DataSource = ds1.Tables[0].DefaultView;
//dataGridView1.DataSource = ds1;
//dataGridView1.DataBindings();
}
private void Form1_Load(object sender, EventArgs e)
{
bindgrid();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(connStr);
ad = new SqlDataAdapter(str2, conn);
ad.Fill(ds2, "secl_et");
dataGridView1.DataSource = ds2.Tables[0].DefaultView;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
SqlConnection conn1 = new SqlConnection(connStr);
ad = new SqlDataAdapter(str3, conn1);
ad.Fill(ds3, "sccl_et");
dataGridView1.DataSource = ds3.Tables[0].DefaultView;
}
the problem is...i want to display data of second table on the click of the button and i have written code for same. But if run this code it u wud find tht everytime u click button, it shows repeated records. Please help me with this....