PC Review


Reply
Thread Tools Rate Thread

How to contruct a ConnectionString to connect to dataset?

 
 
jzdeng@gmail.com
Guest
Posts: n/a
 
      31st Jul 2007
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

 
Reply With Quote
 
 
 
 
Morten Wennevik [C# MVP]
Guest
Posts: n/a
 
      31st Jul 2007
On Tue, 31 Jul 2007 17:37:34 +0200, <(E-Mail Removed)> 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]
 
Reply With Quote
 
jzdeng@gmail.com
Guest
Posts: n/a
 
      31st Jul 2007
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.




 
Reply With Quote
 
=?Utf-8?B?UmFsZiBFaGxlcnQ=?=
Guest
Posts: n/a
 
      31st Jul 2007
If you have buisness objects then you work with these objects like any other
objects/classes. Since .NET 2.0 you use objects as data sources too (or it is
more easier as in the previos versions) but you have to store these objects
back into your database.

Maybe you should look on Visual Studio 2008 and LINQ to SQL- Every edition
of VS2008 (incl. the express editions) contains the ORM designer which mapps
your database tables to objects and back to persistent the state of your
objects.

Or i haven't understand what your problem is.

"(E-Mail Removed)" 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.
>
>
>
>
>

 
Reply With Quote
 
Morten Wennevik [C# MVP]
Guest
Posts: n/a
 
      31st Jul 2007
On Tue, 31 Jul 2007 19:11:18 +0200, <(E-Mail Removed)> 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]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Initialize dataset/adapters with ConnectionString Jorge Gutierrez Microsoft ADO .NET 2 19th Aug 2009 07:30 PM
Change connectionstring Typed dataset =?Utf-8?B?THVj?= Microsoft ADO .NET 5 2nd Aug 2007 01:40 PM
How to change ConnectionString for DataSet at runtime? wilson Microsoft VB .NET 4 4th Aug 2006 06:59 AM
Dynamic connectionstring with Dataset Wizards ? (VS2005) Sagaert Johan Microsoft C# .NET 2 25th May 2006 12:36 PM
DataSet in DLL, ConnectionString from web.config Willy Van den Driessche Microsoft ASP .NET 0 20th May 2006 10:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:09 AM.