Question

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 .

Was it helpful?

Solution

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'.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top