Thursday, March 22, 2012

Deployment of a C# Windows Application connected to SQL Server 2005 Database

Hello all,
I need to consult you in the following problem:
I am developing a windows application in Visual C# 2005 , connected to
an SQL Server 2005 database ,
I want to make deployment for the application so that the user can
have a copy of the application and the database and use it on his
machine even if they dont install the sql server or the visual
studio , i made it using Setup Projects. It was built successfully ,
and created Setup project, when i tested it on another machine ,it
displays the installation wizard ,but it displays an error when trying
to make connection to the database .. the error is:
An error has occurred while establishing a connection to a server ,
when connecting to SQL server 2005,...Could not open a connection to
sql server 2005..
also i logically feel that it is wrong to write an sqlconnection
statement with the name of my machine as the data source , and how to
copy SQL database to the user machine ?
What shall i do? Please Reply...(compjor@.yahoo.com) writes:
> I am developing a windows application in Visual C# 2005 , connected to
> an SQL Server 2005 database ,
> I want to make deployment for the application so that the user can
> have a copy of the application and the database and use it on his
> machine even if they dont install the sql server
Eh? An SQL Server database without SQL Server installed is quite much
a useless piece of bytes.

> i made it using Setup Projects. It was built successfully ,
> and created Setup project, when i tested it on another machine ,it
> displays the installation wizard ,but it displays an error when trying
> to make connection to the database .. the error is:
> An error has occurred while establishing a connection to a server ,
> when connecting to SQL server 2005,...Could not open a connection to
> sql server 2005..
You don't connect to the database. You connect to SQL Server which
will then access the database. But if there is no database to connect to?

> also i logically feel that it is wrong to write an sqlconnection
> statement with the name of my machine as the data source , and how to
> copy SQL database to the user machine ?
There are two possible scenarios:
1) The user already has SQL Server installed on his machine, and don't
want another instance. In this case, give him the option to attach
the database to his server.
2) Bundle SQL Express with your setup, install SQL Express as part of your
setup and attach the database to it.
In both cases you would include the database file in your setup. (Actually,
I would rather use a backup, that the data files directly.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment