连接字符串到数据集? [英] connection string to a dataset?

查看:65
本文介绍了连接字符串到数据集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我已经读过某个地方,数据集可与数据库媲美.这就引出了我的问题:如何在自己的计算机上建立到数据集的连接字符串?

It seems I have read somewhere that a dataset is comparable to a database. Which leads to my question: How do I build a connection string to a dataset on my own machine?

背景:我在数据集中有几个表,我想将它们加入数据集中,然后将合并结果转储到新的数据表中.我已经尝试过很多搜索方法,但是没有任何结果.某些消息甚至暗示了这一点. 强烈不能通过JOIN语句来完成.

Background:  I have several tables in a dataset, and I would like to JOIN them within the dataset, and dump the joined-results into a new datatable. I've tried many searches on how to do this, but came up with nothing. Some sources even hinted strongly it could not be done through a JOIN statement. 

我成功地在数据集中的表之间添加了关系.到目前为止,一切都很好.我在互联网上找到的信息使我相信,只有通过遍历父表中的每个记录,然后选择 子表中的相应记录,然后将自己的结果转储到我动态创建的数据表中.当然有更好的方法吗?因此,我开始怀疑是否可以定义连接(数据最初来自SQL数据库,所以也许 使用New SqlConnection-还是OLEDB?还是其他?)然后连接后,就像使用真实"数据库那样定义命令,数据适配器等,然后在新数据集中填充新数据表.

I successfully added a relationship between the tables in my dataset.  So far, so good.  What I've found on the internet leads me to believe JOINing the records is possible only by iterating through each record in the parent table, selecting the corresponding record in the child table, and then dumping my own results into a datatable I create on the fly.  Surely there is a better way?  So I began to wonder if I could define a connection (the data originally came from a SQL db, so maybe use New SqlConnection -- or OLEDB?  Or something else?)  and once connected, define a command, a data adapter, etc. as I would with a 'real' database, and FILL my new datatable in my new dataset.

可能吗?我已经尝试了几次实验,但到目前为止还没有运气.我不断收到错误消息,提示它找不到数据表(我正在尝试在数据集中查询的数据表).我一直在尝试在连接字符串中使用INITIAL CATALOG, 但无法成功指向数据集中的表.

Possible?  I've tried several experiments, but so far no luck.  I keep getting error msg that it cannot find the datatable (the one I'm trying to query in the dataset).  I've been experimenting with INITIAL CATALOG in the connection string, but have not been able to point successfully to a table in the dataset.

有什么想法吗?谢谢,铝

Any thoughts?  thanks,  Al

PS:我正在VB.Net中工作,但是我有一个问题可能会进入其他论坛?

PS: I'm working in VB.Net but I have a feeling this question might go into some other forum?

推荐答案

数据集是内存中的数据表示.您不能也不需要连接字符串来访问这些数据.如果数据来自SQL db,则在数据库级别执行联接. 
Dataset are in-memory representations of data. You cannot and do not need a connection string to access these data. If the data comes from a SQL db then perform the join at the database level. 


这篇关于连接字符串到数据集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆