Morten
Tue Jul 31 14:40:07 CDT 2007
On Tue, 31 Jul 2007 19:11:18 +0200, <jzdeng@gmail.com> wrote:
> On Jul 31, 12:40 pm, "Morten Wennevik [C# MVP]"
> <MortenWenne...@hotmail.com> wrote:
>> On Tue, 31 Jul 2007 17:37:34 +0200, <jzd...@gmail.com> wrote:
>> > Hi,
>>
>> > We have bunch of DataObejcts/BusinessObjects those used against
>> > database. Now we fetch some data from database into a dataset. How can
>> > we contruct a ConnectionString to connect to this dataset so we can
>> > use those DataObejcts/BusinessObjects?
>>
>> > Thanks
>>
>> Eh? You use a connection string to connect to a database, but you say you already fetched the data and stored it in a DataSet? If so, the DataSet will contain one or more DataTable objects depending on how and what you fetched from the database. The DataTable object may have DataRow objects in its Rows property. The data will be inside these row objects.
>>
>> However, I suspect this is not what you mean. If you want to know how to retrieve data from a database and store it in a DataSet you typically use an SqlDataAdapter (or OleDBDataAdapter) and its Fill method. Or use SqlCommand.ExecuteReader (or OleDBCommand.ExecuteReader) and create a list of objects manually.
>>
>> --
>> Happy coding!
>> Morten Wennevik [C# MVP]
>
> Thanks, Morten
>
> We have some business logic in our DataObejcts/BusinessObjects (such
> as getting data by runing stored procedure, doing some checking
> up ...). Now we load a few tables data into dataset (we don't want to
> lock database for a long time), we want to use our DataObejcts/
> BusinessObjects against it as it against the orignal database. I think
> one way is contruct a connection string to connect to this dataset
> instead of the original database.
>
> Do you have any idea about this?
>
> Thanks very much.
>
>
>
>
>
You can transfer your database data to a temporary file and use OleDB queries against it. There is also the Select method of a DataTable and XPath queries on a DataSet
http://support.microsoft.com/kb/326176
http://msdn2.microsoft.com/en-us/library/89tyw6dw(vs.71).aspx
--
Happy coding!
Morten Wennevik [C# MVP]