andyomeire
Posts: 2
Joined: Sat Sep 14, 2019 5:07 pm

ConnectionString property has not been initialized- issue

I have a Windows application which works fine on the VS IDE it connects successfully and takes me to the main menu of the application on the VS IDE. But when I build the same application on advanced installer using ‘Visual Studio Application as my template and use my logon page after installing the setup it displays error message below
"ConnectionString property has not been initialized"
Please assist.
I am using sqlserver express 2012
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: ConnectionString property has not been initialized- issue

Hi,

This may happen if you are not populating the SQL connection string parameters (i.e. Server, Username, Password, etc) at install time into your config file.

Could you try to follow the steps explained in our "How to save the SQL ODBC connection string in my application config file?" article and see if this helps.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
andyomeire
Posts: 2
Joined: Sat Sep 14, 2019 5:07 pm

Re: ConnectionString property has not been initialized- issue

Hi Daniel,

I have followed the instructions from "How to save the SQL ODBC connection string in my application config file"
And my test connection was successful.
But when I installed the setup in my computer to logon it still displayed the error.


Microsoft .Net Framework
unhandled exception has occured in your application.if you click continue the application will ignore this error and attempt to continue . if you click Quit the application will close immediately........
The connection String property has not been initialized

Below is my connection in App.config :
<appSettings>
<add key="con2" value="Data Source=.\SQLEXPRESS;Initial Catalog=SchoolTimetabledbs;Integrated Security=True"/>
<add key="ClientSettingsProvider.ServiceUri" value="" />

This is the code for connection in my form:
SqlConnection con2 = new SqlConnection(ConfigurationManager.AppSettings["Con2"]);
SqlCommand cmd;

I am using c# vs 2013 ultimate, Mssql 2012 and advanced installer 12.3

The Template I am using to build the setup is Visual Studio Application (see attachment)
Attachments
ainst shoot.jpg
ainst shoot.jpg (78.53 KiB) Viewed 35188 times
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: ConnectionString property has not been initialized- issue

Hello Andy,

From what I can see, you did not declare the User ID and the Password in your connection string - you have declared only the ServerName and the DatabaseName.

For instance, the connection string can look like this:

Code: Select all

connetionString="Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
Additionally, if you have a named instance of SQL Server, you'll need to add that as well:

Code: Select all

"Server=localhost\sqlexpress"
Could you please make these changes and let me know if that helps?

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”