Aru
Aru

Reputation: 51

Program don't see database after creating installation package

I've developed windows form application in c#. I've used for this Microsoft Visual Studio 2010. Now I want to generate installation package (or something that allow me to give my program to people), but I encountered some strange problem.

When I use debug mode - everything is working fine, so I've take compiled program from MyDocuments\Visual 2010\Solution name\Project Name\bin\Debug and give it to my Wife to test it... but on Her computer program doesn't run and give this error:

System.Data.SqlClient.SqlException: An error has occurred with the onset of the network or connect to a SQL Server server. Can not find server or it is not available. Verify that the instance name is correct and that the configuration of SQL Server allow remote connections. (Provider: SQL Network Interfaces, error: 26 - Error locating a specific server / instance)
   in System.Data.ProviderBase.DbConnectionPool.GetConnection (DbConnection owningObject)
   in System.Data.ProviderBase.DbConnectionFactory.GetConnection (DbConnection owningConnection)
   in System.Data.ProviderBase.DbConnectionClosed.OpenConnection (DbConnection outerConnection, DbConnectionFactory connectionFactory)
   in System.Data.SqlClient.SqlConnection.Open ()
   in System.Data.Common.DbDataAdapter.QuietOpen (IDbConnection connection, ConnectionState & originalState)
   in System.Data.Common.DbDataAdapter.FillInternal (DataSet dataset, DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill (DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill (DataTable dataTable)
   in Home_Video_Catalog.HVCDBDataSetFilmsTableAdapters.FilmsTableAdapter.Fill (FilmsDataTable dataTable) in C: \ Documents and Settings \ Aru \ My Documents \ Visual Studio 2010 \ Projects \ Home Video Catalog \ Home Video Catalog \ HVCDBDataSetFilms.Designer.cs: line 868
   in Home_Video_Catalog.MainWindow.MainWindow_Load (Object sender, EventArgs e) in C: \ Documents and Settings \ Aru \ My Documents \ Visual Studio 2010 \ Projects \ Home Video Catalog \ Home Video Catalog \ MainWindow.cs: line 27
   in System.Windows.Forms.Form.OnLoad (EventArgs e)
   in DevComponents.DotNetBar.Office2007RibbonForm.OnLoad (EventArgs e)
   in System.Windows.Forms.Form.OnCreateControl ()
   at System.Windows.Forms.Control.CreateControl (Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl ()
   in System.Windows.Forms.Control.WmShowWindow (Message & m)
   at System.Windows.Forms.Control.WndProc (Message & m)
   in System.Windows.Forms.ScrollableControl.WndProc (Message & m)
   in System.Windows.Forms.ContainerControl.WndProc (Message & m)
   in System.Windows.Forms.Form.WmShowWindow (Message & m)
   in System.Windows.Forms.Form.WndProc (Message & m)
   in DevComponents.DotNetBar.Office2007RibbonForm.WndProc (Message & m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message & m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m)
   at System.Windows.Forms.NativeWindow.Callback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

... so I've thinking that if maybe if I create installer project and create setup for my project it will be ok... but error was the same as previous error code.

I don't quite get it, becouse in my config file in project (app.config and Properties\settings.settings under project) is proper connection string:

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HVCDB.mdf;Integrated Security=True;User Instance=True"

also funny thing is that path in error message is valid on my computer (this is where I've project)

Please help me :)

Upvotes: 0

Views: 409

Answers (1)

Steve
Steve

Reputation: 216313

The syntax Data Source=.\SQLEXPRESS in your connection string refers to the instance of SqlServer Express installed on the local computer.
From the error message I suppose that SqlServer Express is not installed on your target installation computer.
So you have two options:

  • Install Sql Server Express on the target installation machine
  • Change the connection string to refer to your working machine and use the database catalog found there.

    Data Source=YOURMACHINENAME\SQLEXPRESS;Initial Catalog=YOURDATABASENAME;.....
    

Of course, connection to your development machine from another one requires opening the firewall ports, configuring Sql Server for remote connections, configuring the user security.....

Remote connections
Firewall

If you don't want go to the route of installing SQL Server on every machine where your app runs, then you could investigate other database like SQLite, Sql Compact Edition or the non sharing version of SqlServer called LocalDB

Upvotes: 0

Related Questions