How to contruct a ConnectionString to connect to dataset?

  • Thread starter Thread starter jzdeng
  • Start date Start date
J

jzdeng

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
 
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.
 
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.

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.
 
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.
 
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
 
Back
Top