Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good day!

I have a C# program where I'm planning to transfer local records to the Server.

I'm just wondering if it is possible to copy records from client server to the Main Server using SQL Server 2008 R2? The client side has its stand-alone sql database and if it is connected to the main server, the user can copy its records to the main server.

What I have in mind is:

1. Connect the user's laptop its local SQL Server
2. Select all records then place it in a Dataset (Temporarily)
3. Disconnect from the local then connect to the Main Server
4. Transfer the records from the Dataset going to the Main Database (Main Server)


Is this a good way of doing it? I would like to know the best practice or easiest way on how to do it.

Please help...


EDITED:

This is a WinForm Application.

The user/s is/are doing his working outside the office and unable to connect to the main server. There, he needs to save his works in his local DB, then when he's back in the office, he needs to save it to the Main Server.
Posted
Updated 17-Mar-14 19:35pm
v2
Comments
syed shanu 18-Mar-14 0:36am    
Your question is not clear.
Do you want to select recods from local db and then insert the selected records or table to the server db.
If so then you can use linked database.connect your server db from local db and insert all the records u want to the server db.
But i not understand why you use local db and server db.if you clear me with more details what exactly ur doing and what you want i can more assist you.is your applicaiton is web or winform.if its web its more easy.if its winform will your application run in network where your server db reside ?
ErrrCmon! 18-Mar-14 1:38am    
Thank you for the reply. I have updated my question so please feel free to read it again. As for the Linked Database, may I ask for some links you recommend so that I could read about it?

Again, Thank you!
syed shanu 18-Mar-14 1:52am    
linked server is to conect the remote server or any server in networks chk this link.
http://www.codeproject.com/Questions/187591/How-to-query-linked-SQL-server-database

http://msdn.microsoft.com/en-us/library/ff772782.aspx http://stackoverflow.com/questions/4091960/sql-server-linked-server-example-query
I understand what you want .You can create a simple program in winform seperate program or another form in your project .and you already have your local db connection string .and now add server that is in your case main server db connection string in your program and in place one button in a form and in the button click call procedure or run sql script to select data from local db and insert the record to the server db.I think you will have the same table structure in both local and in your server db. for example you ca write query as "INSERT INTO [mainservrIPaddress].[DBName].[dbo].[tblName]
([EMP_NAME])
SELECT EMP_NAME
from [localdbservername].[DBName].[dbo].[tblName]"
ErrrCmon! 18-Mar-14 3:30am    
Ok, I will read this. Thank you Syed for the help!

Yes you can do like that but make one extra column in each table which will show flag where that record is already uploaded or not each time you connect just check flag value and update remaining recored
 
Share this answer
 
Comments
ErrrCmon! 18-Mar-14 1:58am    
Thank you for the reply. Yes of course, flag or a separate counter should be done for tracking purposes. But what I need/like to know is: Are there any other way where I can achieve the same goal without using dataset? Like I just need to run some stored proc in the Main Server to copy the local tables...
sandip1711 20-Mar-14 1:52am    
I think you can do it by
insert into ServerName.Database.dbo.tableName() values() in stored procedure

hope it will work
Even I am not a DB Guy, But I have heard of Replication, So I would be suggesting that to you.

Do Have a look at the following links for further and clear understanding of what I am talking about.

SQL Server Replication Step By Step Guide


Step By Step Replication

Hope it will help you. :)
 
Share this answer
 
Comments
ErrrCmon! 18-Mar-14 2:56am    
Yup, Replication was my second choice BUT I'm only running the express edition of SQL Server 2008 R2... I guess the Publication/Distributor is not part of the Express edition... Meaning, its not free...T_T

PS, Thank you for the info!

Currently, I'm reading the "Linked Database" suggested by another user. His comment can be seen under first my post as a "Comment"
VICK 18-Mar-14 3:12am    
Hmmmm. Sad to not help you completely. :(

But Glad to see you got a path("Linked Database") to think on. :)
ErrrCmon! 18-Mar-14 3:32am    
It's ok Vick, no probs ;) in case you encountered the same problem as mine, atleast you know what to do now :D

Thank you and more power!
VICK 18-Mar-14 3:36am    
Hmm. Positive point.. Thanks Monmonwapo :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900