0

I Have a C# windows form application which does many functions using the data from the database
Now I have a partner whose is working on the database part on his machine
He has database and i have all the forms and the application logic
How should i import his tables from his database engine ? We both use SQL server 2008 R2 with database engines installed
I want that when i send my application to his machine (Say B) i should be able to use the database created by B to run the application of machine A(My machine ) ? We are developing application in Visual studio 2010 Any help would be fantastic .

Up_One
  • 5,213
  • 3
  • 33
  • 65
Srinath Naidu
  • 137
  • 2
  • 11
  • Do you not have a server you can both access that you could hold the database on, then you're both working against the same database rather than having to worry about each others changes and merge issues? – Tanner Mar 20 '14 at 11:40
  • Backup your database, restore it on the server and modify your connection strings to point to the server instead of your local instance – Tanner Mar 20 '14 at 11:44
  • By creating a backup file we get .bak file ! But how should i point the database to the Server ? In visual studio ? – Srinath Naidu Mar 20 '14 at 11:48
  • log on to the server you wish to use, hopefully one that has sql server installed, cop y over the .bak file and create a new DB and restore your .bak file – Tanner Mar 20 '14 at 11:52

2 Answers2

0

Easiest thing to do would be to run full backup on database in question. Below is sample of backup script.

USE YourDatabaseName;
GO
BACKUP DATABASE YourDatabaseName
TO DISK = 'C:\Backup\YourDatabaseName.Bak' 
    WITH FORMAT,
      MEDIANAME = 'C_FullBackup',
      NAME = 'Full Backup of YourDatabaseName';
GO

Documentaion on BACKUP http://technet.microsoft.com/en-us/library/ms187510.aspx#TsqlProcedure

Once backup is done copy the file over to your machine. Now you need to restore database from backup.

RESTORE DATABASE YourDatabaseName
FROM DISK = N'(path to your BAK file)'
WITH FILE = 1,  
MOVE N'(your DB name)' TO N'(your SQL path)database.MDF',  
MOVE N'(your DB name)_LOG' TO N'(your SQL path)database_LOG.LDF',  
NOUNLOAD,  
REPLACE,  
STATS = 10
GO

Documenation on RESTORE http://technet.microsoft.com/en-us/library/ms186858.aspx

0

If it gets on a shared server, you can pull from different sources using different connection strings (using your database or his database, etc.). Here's a sample of connecting to 2 different database using 2 different connection strings in the Config file.

<connectionStrings>
    <add name="Conn1" connectionString="Data Source=YourDataSource;Integrated Security=True"
        providerName="System.Data.SqlClient" />
  <add name="Conn2" connectionString="Data Source=YourDataSource;uid=YourUserID;pwd=YourPassword;" providerName="System.Data.OracleClient" />
</connectionStrings>

Copying a SQL Server Database will be helpful also, because if a database is on his local machine and neither of you are connected via LAN or some intranet, you can't access it. It needs to be copied or put on a shared server/location where both of you can access it. Otherwise, see the link on how to copy the database.

Copying data from one database to another. This link should also help accomplish the meat of your question.

However, if you solely want "B" to be able to access it, and you don't care about the access, then just deploy your executable and change the connection string in his config file.

Also, see Vladimir's post regarding 'Backup'.

Community
  • 1
  • 1
Mark C.
  • 6,332
  • 4
  • 35
  • 71