Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having application with database... i have created database in sql server 2008.. if i move my application(code) alone to any other system, it not working...(server is not found error i m getting) so i need to send code along with database to other system and it should work...
how can i do tat...
Posted
Comments
choudhary.sumit 11-Dec-12 4:24am    
are the systems are connected through intranet or LAN?
selva_1990 11-Dec-12 4:26am    
no.. just single user...
choudhary.sumit 11-Dec-12 4:29am    
ok, then just build a backup, keep it in you application directory, take away your code, restore it on the machine either through code or directly from the sql server wizard. you must have sqlserver installed on client machine in that case!
Kiran Susarla 11-Dec-12 4:26am    
so you are saying that you will move your code to one machine and the database will be in another machine. If yes, want to know if these two machines are connected through intranet?
selva_1990 11-Dec-12 4:30am    
no no just single user machine...., is it possible to send database too to other machine... if so how????

You have to create a text file/ xml file/ .Net config file to store server name/IP and database name and save it in app directory. Then you have to read it on app startup and connect to the server.

please let me know it helped or not?
 
Share this answer
 
v2
Comments
selva_1990 11-Dec-12 4:36am    
client does not have sql server installed in system....
so i need to send application and db to client machine and it should work...
AnkitGoel.com 11-Dec-12 4:39am    
Either you need to install sql server on same machine
OR
You need to install or another machine

In both case you have to specify SQL Server IP and DB Name. Which as i said, you can stored in anyone of the above files.
AnkitGoel.com 11-Dec-12 4:41am    
which option do u want to use?
selva_1990 11-Dec-12 5:02am    
k if client having sqlserver... how can i send code and backup... suppose if i m having app.bak(db backup) how can i attach this to my code directory...
As per your reply to my comment, yes you can send database as well (though you cannot copy it directly) to other machine.

Approach 1:
If you want to send the database along with data, you can
1. create the backup of your database using T-SQL BACKUP command.
2. Copy the backup file to your target file.
3. Restore the database on target machine using T-SQL RESTORE command.
4. Once database is restored modify the connection string in your code to point to new server and restored database.

Approach 2:
If you want to copy only the schema, generate database scripts from SQL Server Management studio and execute them on the target machine. Once the database is created modify the connection string in your code to point to new server and restored database.
 
Share this answer
 
Comments
selva_1990 11-Dec-12 4:50am    
client doesnt know about modify connection, without modification client need to run...
if i send my application and db to you, it should work without any modification... i need that method...
Kiran Susarla 11-Dec-12 4:59am    
In this case you can create an installer (.msi) using Visual Studio setup and deployment project or WIX for your app. Using the setup you can create install your app binaries and create the database on the target machine.
During the installation if you want you can prompt the user to enter the server name and save it in registry. Your app can read this entry and use it to connect to the database.

Hope I am clear.
selva_1990 15-Dec-12 11:04am    
thank you

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