Hi all,
Good Day! I am using C# Visual Studio 2008 and SQL server 2008. My application what i am doing is, i have 9 tab pages in single tab control. In variable ID i am getting tab page index in 2 power like if index is 0 then ID is 2^0=1. In this i have remote database table tmessage_temp. from this remote data base table i am reading fldTo column for getting ID. if fldTo is 3, then tab page 1 and tab page 2 is set. because of 9 tab pages i am using loop from 0 to 8. in this loop i am entering into switch(ID). In this i am reading data from remote database and displaying using data grid view. It is not a problem to view in data grid view control for single case. If loop condition coming into switch case from 1 to 3, in data grid control display only the last case. In this i want to display all one by one in single data grid control. How to do this. Can you please giveme a way to do it.
And my code is:
for (int i = 0; i < 9; i++)
{
ID = Convert.ToInt32(Math.Pow(2, i));
switch (ID)
{
case 1:
string cmdtxt = "Select fldMmsg from tmessage_temp where fldTo=" + ID + "";
cmd = new SqlCommand(cmdtxt, cn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
DataSet ds = new DataSet();
sdr.Fill(dt);
ds.Tables.Add(dt);
break;
case 2:
string cmdtxt1 = "Select fldMmsg from tmessage_temp where fldTo=" + ID + "";
cmd = new SqlCommand(cmdtxt1, cn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter sdr1 = new SqlDataAdapter(cmd);
DataSet ds1 = new DataSet();
DataTable dt1 = new DataTable();
sdr1.Fill(dt1);
ds1.Tables.Add(dt1);
dataGridView2.DataSource = ds1;
MessageBox.Show("two");
break;
}
}Thanks & Regards Sasi ................. Go Green