Click here to Skip to main content
15,905,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an assignment that involves creating a C# windows application that reads and writes from a database that I created using SQL Server 2005. the problem now is I have to give the code and the running application to my professor on a CD. so can anyone please tell me how can I deploy my application with the database on the CD so that the professor can run the application from the cd or install it on his computer and run it from there and still it remains connected to the database and reads and writes to it. thank you very much.


P.S in my application i connected to the database using add data source from visual studio 2008.
Posted
Comments
yesotaso 13-Jun-11 14:06pm    
Provided your professor have database server installed, Solution 1 is the answer. If not AFAIK SqlCE installation can be included in your setup but that does not fit "SQL 2005" definition :)

You could create a custom action to install the database - see here[^].
 
Share this answer
 
first of all it is not possible to be still connected unless if your professor have a SQL server intalled in his PC and you have the same server name, but there is still solution to your problem.

1.) instead of connecting to server use the original database to connect (the .mdf file).
2. Copy your database(.mdf) to the debug folder.
3. then use this connection.
string databasePath = Application.StartupPath + "\database.mdf";
string connectionString = "DataSource=.\SQLEXPRESS; AttachDbFilename =" + databasePath +";Integrated Security=True;Connect Timeout=30;User Instance=True"
System.Data.SqlClient.SqlConnection  con = new System.Data.SqlClient.SqlConnection(connectionString);
con.open();


IMPORTANT: include the database(mdf) to the package.
 
Share this answer
 
v2
 
Share this answer
 

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