using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DB;
using System.Threading;namespace SourceReadDemo
{
class Class1
{
private bool flag;//用于关闭线程
private bool flag1;
private Thread thread1;
private Thread thread;//定义一个线程
SqlConnection con = new SqlConnection("server=.;database=pubs;uid=sa;pwd=");
DataSet dss = new DataSet();//声明全局的dataset
public void start()
{
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc(sql)));//当前上下文中不存在名称“sql” ????
thread1 = new Thread(new ThreadStart(threa1(ds)));当前上下文中不存在名称“ds”
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先 }
////线程回调函数
private void threadProc()
{
while (flag)
{ DataBind(sql);)));//当前上下文中不存在名称“sql” ????
Thread.Sleep(100);
}
}
private void threa1()
{
while (flag1)
{
qu(ds);)));//当前上下文中不存在名称“ds” ????
Thread.Sleep(1000);
} }
public DataSet DataBind(string sql)
{ try
{ SqlDataAdapter sdat = new SqlDataAdapter(sql, con);
sdat.Fill(dss,"student");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
con.Close(); }
return null;
}
public DataSet qu(DataSet ds)
{
// DataSet ds = new DataSet();
try
{
if (ds.Tables["student"].Rows.Count != 0)
{
MessageBox.Show("发送数据");
return ds;
}
else
{
MessageBox.Show("数据已经没有了");
flag = false;
flag1 = false;
return null;
}
}
catch (Exception x)
{
MessageBox.Show(("等待数秒后请按‘确定’"));
}
return ds;
}
}
}
该怎么把他改好啊?
谢谢帮忙
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DB;
using System.Threading;namespace SourceReadDemo
{
class Class1
{
private bool flag;//用于关闭线程
private bool flag1;
private Thread thread1;
private Thread thread;//定义一个线程
SqlConnection con = new SqlConnection("server=.;database=pubs;uid=sa;pwd=");
DataSet dss = new DataSet();//声明全局的dataset
public void start()
{
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc(sql)));//当前上下文中不存在名称“sql” ????
thread1 = new Thread(new ThreadStart(threa1(ds)));当前上下文中不存在名称“ds”
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先 }
////线程回调函数
private void threadProc()
{
while (flag)
{ DataBind(sql);)));//当前上下文中不存在名称“sql” ????
Thread.Sleep(100);
}
}
private void threa1()
{
while (flag1)
{
qu(ds);)));//当前上下文中不存在名称“ds” ????
Thread.Sleep(1000);
} }
public DataSet DataBind(string sql)
{ try
{ SqlDataAdapter sdat = new SqlDataAdapter(sql, con);
sdat.Fill(dss,"student");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
con.Close(); }
return null;
}
public DataSet qu(DataSet ds)
{
// DataSet ds = new DataSet();
try
{
if (ds.Tables["student"].Rows.Count != 0)
{
MessageBox.Show("发送数据");
return ds;
}
else
{
MessageBox.Show("数据已经没有了");
flag = false;
flag1 = false;
return null;
}
}
catch (Exception x)
{
MessageBox.Show(("等待数秒后请按‘确定’"));
}
return ds;
}
}
}
该怎么把他改好啊?
谢谢帮忙
ds是一个DATASET,你那找不到的那句是要做DATASET的绑定,关键是,ds没定义啊
LZ哪儿找的程序片段?