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;//定义一个线程
//public delegate void MyInvoke(DataSet ds);//定义一个委托
SqlConnection con = new SqlConnection("server=.;database=pubs;uid=sa;pwd=");
DataSet ds = null;//声明全局的dataset
string sql = "";
public DataSet start(string sql)“SourceReadDemo.Class1.start(string):并非所有的代码路径都返回值 {
this.sql = sql;
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc));
thread1 = new Thread(new ThreadStart(threa1));
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先
}
////线程回调函数
private void threadProc()
{
while (flag)
{ DataBind();
Thread.Sleep(100);
}
}
private void threa1()
{
while (flag1)
{
qu();
Thread.Sleep(1000);
} }
public DataSet DataBind()
{
DataSet dss = new DataSet();
try
{
if (sql != "")
{
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()
{
try
{
ds = ds.Tables["student"];无法将类型“System.Data.DataTable”隐式转换为System.Data.DataSet” }
catch (Exception x)
{
MessageBox.Show(("等待数秒后请按‘确定’"));
}
}
public DataSet returnDS
{
get
{
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;//定义一个线程
//public delegate void MyInvoke(DataSet ds);//定义一个委托
SqlConnection con = new SqlConnection("server=.;database=pubs;uid=sa;pwd=");
DataSet ds = null;//声明全局的dataset
string sql = "";
public DataSet start(string sql)“SourceReadDemo.Class1.start(string):并非所有的代码路径都返回值 {
this.sql = sql;
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc));
thread1 = new Thread(new ThreadStart(threa1));
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先
}
////线程回调函数
private void threadProc()
{
while (flag)
{ DataBind();
Thread.Sleep(100);
}
}
private void threa1()
{
while (flag1)
{
qu();
Thread.Sleep(1000);
} }
public DataSet DataBind()
{
DataSet dss = new DataSet();
try
{
if (sql != "")
{
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()
{
try
{
ds = ds.Tables["student"];无法将类型“System.Data.DataTable”隐式转换为System.Data.DataSet” }
catch (Exception x)
{
MessageBox.Show(("等待数秒后请按‘确定’"));
}
}
public DataSet returnDS
{
get
{
return ds;
}
}
}
}
解决方案 »
- (100)分实现新浪微博api OAuth验证(希望能有一个发布一条微博的例子)
- 请教点击某个按钮,弹出一个对话框,来修改一些数值
- 有几个函数,只有函数名不同,如何以更简单的形式编写这几个函数,或用一个函数代替这几个函数?
- 谁能给我个winmm.dll里面可引用的函数及说明啊?
- 如何新建进程?
- 服务器 和客户端响应问题 急急
- 关于排序器的问题,大哥大嫂大姐,大妹子们,帮小弟看看呗,亲,求您了
- 求大家一定要帮帮我,.net 2003 的安装使用问题
- 怎么转换BCD编码啊?
- AppDomain中跨域委托,在Console程序中可用,在Asp.net中提示调用的目标发生异常
- XML数据是否能在绑定前整理?
- [快速结贴]如何给webservice传递QueryString参数?webservice应该如何设计此方法?
ds = ds.Tables["student"];无法将类型“System.Data.DataTable”隐式转换为System.Data.DataSet”
ds.Tables["student"];得到的是有个DataTable,所以没办法转换
直接DataTable dt =ds.Tables["student"];这样才可以
this.sql = sql;
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc));
thread1 = new Thread(new ThreadStart(threa1));
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先
}DataTable dt = ds.Tables["student"];
this.sql = sql;
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc));
thread1 = new Thread(new ThreadStart(threa1));
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先
要return 一个DataSet的对象
}
this.sql = sql;
//启动线程
flag = true;
flag1 = true;
thread = new Thread(new ThreadStart(threadProc));
thread1 = new Thread(new ThreadStart(threa1));
thread.Start();
thread1.Start();
thread.Priority = ThreadPriority.Highest;//将读数据线程优先
}
{
try
{
DataTable dt = ds.Tables["student"];
}
catch (Exception x)
{
MessageBox.Show(("等待数秒后请按‘确定’"));
}
}
现在前面的没事了
后面这个方法又不行了!
这个的道理是一样的啊
没有返回值