怎么用ADO来读取TEXT数据?

nieer 2003-08-18 10:54:35
怎样设置connectstring?
...全文
49 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bJiao 2003-08-19
  • 打赏
  • 举报
回复
没有办法直接读取一个text文件。除非你的文件是一个recordset保存出来的,那样
可以用:rs.Open Source:="D:\ Authors.rs", Options:=adCmdFile这样的语句来处理。
nieer 2003-08-19
  • 打赏
  • 举报
回复
这不是连接SQL数据库吗?
zqfleaf 2003-08-19
  • 打赏
  • 举报
回复
先用ODBC建一个用户DSN,名字如aa
Provider=MSDASQL.1;Persist Security Info=False;Data Source=aa
nieer 2003-08-19
  • 打赏
  • 举报
回复
是吗?
谢谢.
这是以个c#做的报表例子,      //打开连接      conReport.Open();      //准备连接对象以把获取的数据放入数据集      cmdReport.CommandType = CommandType.Text;      cmdReport.Connection = conReport;      cmdReport.CommandText = "Select TOP 5 * FROM Products Order By ProductName";      //从命令对象中读取数据      drReport = cmdReport.ExecuteReader();      //有了ADO.NET,可把读取来的数据直接加载到数据集中      dsReport.Tables[0].Load(drReport);      //关闭读取及连接      drReport.Close();      conReport.Close();      //为查看器提供本地报表数据 this.reportViewer1.LocalReport.ReportEmbeddedResource =      "报表问题.rptProductList.rdlc";      //准备报表数据源      ReportDataSource rds = new ReportDataSource();      rds.Name = "dsProduct_dtProductList";      rds.Value = dsReport.Tables[0]; this.reportViewer1.LocalReport.DataSources.Add(rds);      //加载报表查看器 this.reportViewer1.RefreshReport();    }    catch (Exception ex)    {      //显示错误信息      MessageBox.Show(ex.Message);    }    finally    {      //检查连接是否仍然打开,如果是,关闭它。      if (conReport.State == ConnectionState.Open)      {        conReport.Close();      }

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧