主题:[讨论]C#线程的问题
错误提示:在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级
源码:
private void button2_Click(object sender, System.EventArgs e)
{
try
{
ThreadStart ts = new ThreadStart(GetDataSound);
Thread t = new Thread(ts);
t.IsBackground=true;
t.Start();
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
调用如下的方法:
private void GetDataSound()
{
ds = new DataSet();
string strsql = "select wd as 网点,sum(sm) as 银行选择人数 from("+
" select (select sername from kglhzsmk.zx_card_netrecord@card where"+
" serid=(select serid from kglhzsmk.nb_xzbm_tmp@card d where d.xzbm=substr (a.hswd,1,5))) as wd"+
" ,count(*) as sm from cj_slbsmt a ,cj_jcxxlrb1 b"+
" where a.txm=b.txm and b.sqyhmc='"+xzyh+"' group by a.hswd) dd group by dd.wd";//网点
ds.Merge(mybase.ExecSelectNoKey
ds.Tables["网点"].DefaultView.AllowDelete = false;
ds.Tables ["网点"].DefaultView.AllowEdit = false;
ds.Tables["网点"].DefaultView.AllowNew = false;
this.jdDataGrid1.DataSource = ds.Tables["网点"].DefaultView;
}
各位大虾,指点一下,小弟急啊!!
源码:
private void button2_Click(object sender, System.EventArgs e)
{
try
{
ThreadStart ts = new ThreadStart(GetDataSound);
Thread t = new Thread(ts);
t.IsBackground=true;
t.Start();
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
调用如下的方法:
private void GetDataSound()
{
ds = new DataSet();
string strsql = "select wd as 网点,sum(sm) as 银行选择人数 from("+
" select (select sername from kglhzsmk.zx_card_netrecord@card where"+
" serid=(select serid from kglhzsmk.nb_xzbm_tmp@card d where d.xzbm=substr (a.hswd,1,5))) as wd"+
" ,count(*) as sm from cj_slbsmt a ,cj_jcxxlrb1 b"+
" where a.txm=b.txm and b.sqyhmc='"+xzyh+"' group by a.hswd) dd group by dd.wd";//网点
ds.Merge(mybase.ExecSelectNoKey
ds.Tables["网点"].DefaultView.AllowDelete = false;
ds.Tables ["网点"].DefaultView.AllowEdit = false;
ds.Tables["网点"].DefaultView.AllowNew = false;
this.jdDataGrid1.DataSource = ds.Tables["网点"].DefaultView;
}
各位大虾,指点一下,小弟急啊!!