Groups | Blog | Home
all groups > dotnet ado.net > july 2007 >

dotnet ado.net : How to contruct a ConnectionString to connect to dataset?


Ralf Ehlert
7/31/2007 12:06:14 PM
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.

[quoted text, click to view]
jzdeng NO[at]SPAM gmail.com
7/31/2007 3:37:34 PM
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
jzdeng NO[at]SPAM gmail.com
7/31/2007 5:11:18 PM
On Jul 31, 12:40 pm, "Morten Wennevik [C# MVP]"
[quoted text, click to view]

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.



Morten Wennevik [C# MVP]
7/31/2007 6:40:35 PM
[quoted text, click to view]

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]
7/31/2007 9:40:07 PM
[quoted text, click to view]

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!
AddThis Social Bookmark Button