473,810 Members | 2,935 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 functionnalitie s 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 functionnalitie s 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 1329
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**********@c om.msn_swapwrot e in message
news:%2******** ********@TK2MSF TNGP04.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 functionnalitie s 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 functionnalitie s 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**********@n othinks.comwrot e in message
news:%2******** ********@TK2MSF TNGP04.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**********@c om.msn_swapwrot e in message
news:%2******** ********@TK2MSF TNGP04.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 functionnalitie s 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 functionnalitie s 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 functionnalitie s 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**********@c om.msn_swapwrot e in message
news:%2******** ********@TK2MSF TNGP04.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 functionnalitie s 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 functionnalitie s 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
12143
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 slow my update code amounts to dataTable.BeginLoadData() dataSet.EnforceConstraints = false tr for(iRowHandle = 0; iRowHandle < iLimit; iRowHandle++
2
100399
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 columns "col1", "col2", "col3" in my DataTable "Table1", I need to basically be able to do this: select distinct col2 form Table1 I tried doing this: DataRow ResultsRowArray = MyTable.Select("distinct col2");
3
31371
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 the columns from V1 that I need to the V2 table. After creating the tables (works 100%) i run this code:
7
1782
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 array of some sorts, private string test; .... I don't want to get the value by saying: test but test Can this only be done with a DataTable? But DataTables are for databases
4
2580
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 contents on certain fields. The grouping/filtering is "remembered" for each user via a cookie. The problem is works like this: User A applies a filter on Project Manager. User B filters by Department. User B groups by Project Manager (NOTE -...
2
2482
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 which the third one is blank): id Number Description 1 1 Desc1 2 1 Desc2
2
4122
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 reason i need to do this is I am having to traverse a large number of databases and the with iteration the process is taking quite a long time. Thanks in advance!
7
3851
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) Transferring the record from the new datatable back to the database. Any ideas? Thanks
3
1982
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, DataTable946. How can I create a select query on table beginning with the word "DataTable"? Find the table 9 characters in length beginning with the word "DataTable" and then do the select query from it. Thanks for your help.
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
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 we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.