473,503 Members | 13,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On DataTable, two databases

Hi,

I'm building an ASP.Net corportate web application.

One module of the application consists of a web service that manages users.
Due to the history of the organisation, there is several databases accross
the network and users data are unfortunatelly not stored in the same DB.

What I want to reach is to provides users informations (read only
informations) through the web service to hide the complexity of the data.

I've created a UsersDataTable (using the VS Designer) that have 8 columns.
Half of the columns are taken from the 1st DB (SQL Server) and the other
half columns are taken from the 2nd DB.

FYI, there is one nvarchar column in the two tables of the two sources that
identify uniquely the rows.

I want to keep the maximum of functionnalities of the VS designer and I'd
like (if possible) to avoid duplicating the data between the two sources.
I've thought about the linked server functionnalities between the two sql
server, but later, there's a probability that other platform will be
queried, in fact, I'd like a general neutral solution (pure ADO.Net).

What the best way to correctly handle the two sources ?
Thanks for your feedbacks.
Steve
May 14 '07 #1
3 1314
Use a Distributed Query.

See the following articles:

http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx
http://msdn2.microsoft.com/en-us/library/ms188721.aspx

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Steve B." <st**********@com.msn_swapwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,

I'm building an ASP.Net corportate web application.

One module of the application consists of a web service that manages
users.
Due to the history of the organisation, there is several databases accross
the network and users data are unfortunatelly not stored in the same DB.

What I want to reach is to provides users informations (read only
informations) through the web service to hide the complexity of the data.

I've created a UsersDataTable (using the VS Designer) that have 8 columns.
Half of the columns are taken from the 1st DB (SQL Server) and the other
half columns are taken from the 2nd DB.

FYI, there is one nvarchar column in the two tables of the two sources
that identify uniquely the rows.

I want to keep the maximum of functionnalities of the VS designer and I'd
like (if possible) to avoid duplicating the data between the two sources.
I've thought about the linked server functionnalities between the two sql
server, but later, there's a probability that other platform will be
queried, in fact, I'd like a general neutral solution (pure ADO.Net).

What the best way to correctly handle the two sources ?
Thanks for your feedbacks.
Steve


May 14 '07 #2
That applies only when I'm querying two databases. It requires not only that
the "main" sql server has access to the second sql server, but also that
both servers are on the same network.
My case applies to this conditions, but I do not want to be blocked if
tomorrow this requirements are not met.

Imagine if you work with extranet partners with only http access, or even a
"simple" xml file, etc...
I'd like to be able to handle such scenarios and the only way I found, is to
fill the datatable row by row, by querying the DBs as often as required...

Thanks,
Steve

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Use a Distributed Query.

See the following articles:

http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx
http://msdn2.microsoft.com/en-us/library/ms188721.aspx

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Steve B." <st**********@com.msn_swapwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi,

I'm building an ASP.Net corportate web application.

One module of the application consists of a web service that manages
users.
Due to the history of the organisation, there is several databases
accross the network and users data are unfortunatelly not stored in the
same DB.

What I want to reach is to provides users informations (read only
informations) through the web service to hide the complexity of the data.

I've created a UsersDataTable (using the VS Designer) that have 8
columns. Half of the columns are taken from the 1st DB (SQL Server) and
the other half columns are taken from the 2nd DB.

FYI, there is one nvarchar column in the two tables of the two sources
that identify uniquely the rows.

I want to keep the maximum of functionnalities of the VS designer and I'd
like (if possible) to avoid duplicating the data between the two sources.
I've thought about the linked server functionnalities between the two sql
server, but later, there's a probability that other platform will be
queried, in fact, I'd like a general neutral solution (pure ADO.Net).

What the best way to correctly handle the two sources ?
Thanks for your feedbacks.
Steve



May 14 '07 #3


DataSet.Merge works well.

---------------
IF you have 2 seperate tables (in your dataset) .
Like
ds.Employee
ds.Dept
-----------
It works well on one table, but you have different PK's (as mentioned)

like
ds.Employee
ds.Employee
(perhaps the first one has full time employees, and the second
one has part time employees)
EmployeeDS ds1 = new EmployeeDS();
//populate ds1 with full time emps.

EmployeeDS ds2 = new EmployeeDS();
//populate ds2 with parttime emps.

EmployeeDS dsmerged = ds1.Merge( ?? ds2 //multi overloads here) ;
...

Merging "the same rows based on the PK" is a totally different story, and
this permutation doesn't play nice.
HOWEVER, it is doable.
ds.Employee ( EmpID , LastName, FirstName , SSN , HireDate , DOB ,
ReleaseDate )

Lets say database1 has EmpID, LastName, FirstName
database2 has EmpID , HireDate , DOB , ReleaseDate

is it ~possible (but not as cleancut as above) to do this. but .Merge likes
different row, you'll have to play with it to get (same rows (based on
EmpID) different columns to work)

EmployeeDS ds1 = new EmployeeDS();
//populate ds1 EmpID, LastName, FirstName.

EmployeeDS ds2 = new EmployeeDS();
//populate ds2 EmpID , HireDate , DOB , ReleaseDate.

EmployeeDS dsmerged = ds1.Merge( ?? ds2 //multi overloads here) ;

The key is EmpID is the primary key defined in the DataSet.

.........

And the last permutation is

EmployeeDS ds1 = new EmployeeDS();
//populate ds1 EmpID, LastName, FirstName.

EmployeeDS ds2 = new EmployeeDS();
//populate ds2 EmpID , LASTNAME , HireDate , DOB , ReleaseDate

Notice lastname is on both db's. Lets say its out of sync (someone got
married??), you'll have issues here.

//I want to keep the maximum of functionnalities of the VS designer//

Dump the designer for populating the data. Write your own code to populate
ds1 and ds2.
You'll never win with the auto generated table adapters.
PS
ds.Employee ( EmpID , LastName, FirstName , SSN , HireDate , DOB ,
ReleaseDate )

Note, that everything in your ds will have to allows nulls, except for
EmpID........

"Steve B." <st**********@com.msn_swapwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,

I'm building an ASP.Net corportate web application.

One module of the application consists of a web service that manages
users.
Due to the history of the organisation, there is several databases accross
the network and users data are unfortunatelly not stored in the same DB.

What I want to reach is to provides users informations (read only
informations) through the web service to hide the complexity of the data.

I've created a UsersDataTable (using the VS Designer) that have 8 columns.
Half of the columns are taken from the 1st DB (SQL Server) and the other
half columns are taken from the 2nd DB.

FYI, there is one nvarchar column in the two tables of the two sources
that
identify uniquely the rows.

I want to keep the maximum of functionnalities of the VS designer and I'd
like (if possible) to avoid duplicating the data between the two sources.
I've thought about the linked server functionnalities between the two sql
server, but later, there's a probability that other platform will be
queried, in fact, I'd like a general neutral solution (pure ADO.Net).

What the best way to correctly handle the two sources ?
Thanks for your feedbacks.
Steve


May 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12053
by: Chris | last post by:
I'm using a DataTable in my application. I am able to load rows into the DataTable quickly. What's puzzling me, however, is that when I update a set of cells in the DataTable, the update is really...
2
100335
by: Jim H | last post by:
I am storing incoming data in memory using a DataTable. After I'm done retrieving the data I need to get the distinct rows. I tried using DataTable.Select but that doesn't work. If I have...
3
31356
by: Ryan Ternier | last post by:
I gota scoot here so I gota make it quick :) I'm doing a conversion from 2 different databases (2 different software versions) I have each table stored in a Datatable, and I'm going to append...
7
1762
by: Tinus | last post by:
Hello all, I was wondering... Is there a way to create a Array so that I can call a value with a name i.s.o. a index number? Something similar like a DataTable. This is what I want: Declare a...
4
2545
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
2
2449
by: Roy | last post by:
Hi all, I do have a datatable that looks like: id Number Description 1 1 Desc1 2 1 Desc2 3 2 Desc3 I need this datatable looks like (with 4 rows...
2
4052
by: RSH | last post by:
Hi, I have a situation where I am querying SQL Server and bringing back a Dataset. Is there a way to dump the datatable to a delimited text file without iteration through the datatable? The...
7
3837
by: Wayne Gibson | last post by:
Hi All, Was wondering if anybody could help. I'm currently trying to copy a record from datatable to another. I have two problems: 1) Transferring the record from one datatable to another. 2)...
3
1952
by: wbw | last post by:
I will be querying from many databases and all of the databases that all have a table beginning with word the "DataTable", but are named differently for example DataTable981911, DataTable98174,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.