-1

I have a project in C# which is created in Visual Studio 2013. I want to create an installer using Install Shield free version. I created an installer and trying to run it on other computer but, when I run it and trying to log into program, I have problems about mysql database. Error message is:

Unhandled exception has occured in you application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.

Cannot connect.

If I click on details button, I have a serie of errors which refers on Mysql. Example:

System.Exception: Cannot connect ---> MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at simulator.ConnConfig.getConnection()

simulator is the name of the project. ConnConfig is a class where is the connection and getConnection() is a function from ConnConfig which return connection. II tried to install on another computer .NET Framework 4.5.2, SQL Server, but also didn't worked. In my project, I use localhost server where I have a database with 2 tables. My question is, is there any possibility to add that localhost database to installer and use it on another computer? And what redistributables requires this operation? Also, I have installed on computer .NET Framework 4.5, Sql Server 2012..but when I try do add them in InstallShield via Redistributables, but it keeps saying that Needs to be downloaded. Why?

UPDATE

I have this Class where I make the conenction. But I receive error: Additional information: Illegal characters in path. at that line:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;

namespace simulator
{
    class ConnConfig
    {
        private static string conn = "Data Source=c:\aplicatie.db;Version=3;Password=myPassword;";
        public static SQLiteConnection connect = null;

        private ConnConfig()
        {

        }
        public static SQLiteConnection getConnection()
        {
            SQLiteConnection connect = null;
            try
            {
                connect = new SQLiteConnection(conn);
                connect.Open();// here I receive the error
                return connect;
            }
            catch (SQLiteException e)
            {
                throw new Exception("Cannot connect", e);
            }
        }
    }
}

UPDATE 3

In that class I make the connection to database. In the other forms I just use tables and their data. For connection to program, I use a login form which uses this class to getConnection(). I created that database by adding an ADO.NET in simulator project. And with that, it comes those 2 tables that I already have in localhost server. So, Is ok if I have to create another empty database with new tables, but where to include that code or how to use it, because I don't get how that script works..where should I put it?

15
  • Your application is lacking basic error handling. Unable to connect to any of the specified MySQL hosts. means your application cannot reach the database. Make sure it's reachable by the other computer. Commented Mar 21, 2015 at 15:54
  • And how can I do that? That's my problem Commented Mar 21, 2015 at 15:55
  • Is your database going to be installed on each client or are you going to have a server? Also you mention MySQL and SQL Server which one is it? These two tables are large or small? Commented Mar 21, 2015 at 15:59
  • Aaa my mistake, I did not know exactly, I said to them say. Is MySql. Well, I want to be installed on each client. I create it and they just have to use it without internet connection. They are pretty large, yes, at least will be at the final of the project and is possible to create more tables but only one database will be. Commented Mar 21, 2015 at 16:07
  • How many columns or rows? Two tables doesn't seem that big. Is this DB IO intensive? Write or Read? Commented Mar 21, 2015 at 16:17

3 Answers 3

2

If your database is going to be installed on each client and your tables are not massive you might want to look at something lighter like SQLite which doesn't need any installation just the dlls and is very fast and efficient and only runs when your program does.

As for for the Needs to be Downloaded issue, it seems you have not setup your prerequisite correctly, you an correct this by following the steps in this article Adding InstallShield Prerequisites, Merge Modules, and Objects to Basic MSI and InstallScript MSI Projects

You might want to look into determining if MySQL is the right solution for you.

SQLite vs MySQL vs PostgreSQL: A Comparison Of Relational Database Management Systems

And to see the limitations of SQLite SQLite

Because honestly seems like overkill to install MySQL on every system. If you had one server with MySQL on the network, okay. But on every system seems like a bad idea.

As far as connecting to an SQLite database here is a List of Connection Strings for SQLite

See this topic on how to create Databases and tables Create SQLite Database and table

Sign up to request clarification or add additional context in comments.

13 Comments

Interesting, I know about SQLite but I don't really know how to use it. I gone to their website, but I don't know what to download and how to include it in my project..can you help me with that or is too much?
Actually very easy. You can get the NuGet package and use it with ADO.NET, Entity Framework and LINQ. Just get the official NuGet package
I see. Well, I will try it right now. Thank you very much. If something goes wrong or I'm lost, you have time to help me later?
Yeah no problem or you can ask another question
Ok, so I added a ADO.NET database and it found my database with those 2 tables. To use this database which now, I guess, is included in project, how do I have to modify string connection? I have to mention that I have a separate class where I do the connection.
|
1

My guess is your program doesn't bundle up the database alongside the setup upon deployment. This may be due to the fact that you didn't mark your database as a Data File in the Project Files. Try this, right click on your project name in Solution Explorer and select Properties from Menu. From the horizontal tabs click on the Publish Tab. Under Install Mode and Settings click the Application Files button. A dialog box appears with all Application files. Set your database Publish Status to Data File from the drop down on the corresponding cell. This way your database will be bundled together with the setup upon publishing. Hope this helps.

6 Comments

Sure, I see. But I have a big big question :)) I deploy mysql database with installer. But, I can run the software on another pc where mysql server is not installed?
Kindly rephrase your quesion, what do you mean in another pc where mysql is not installed. But if you mean installing the setup on another pc that has no MySql then you will have to set the Copy Local of MySql.Data reference to true(you do this by opening references on Solution Explorer then right clicking MySql.Data and setting Copy Local property to true.). This way the MySql.Data.dll is bundled with your setup upon publishing. I also think you will need to install the MySql connector too as its the driver your database uses to interact with your database
Thank you very much. I know that my english isn't so well, but you succeed to understand me :))) I will try this solution, is something that I haven't tried yet.
:) Ok hope bundling the database with your setup upon publishing does solve your problem. If any of the given answers solves your problem mark that entry as an answer to help those who'll ever need to know the solution to you problem.
Unfortunately, when I run it on another pc and try to connect to database, I receive: Could not load file or assembly 'MySql.Data, Version=6.9.5.0,Culture=neutral'..This assembly is built by a tuntime newer than the currently loaded runtime and cannot be loaded. I tried to run it on win xp and the project is builded with .net framework 3.5 sp1, which exists on pc. What do you think is the problem?
|
-1

You can access SQLite via ODBC.

3 Comments

I was planned to add comment to carbo18's answer but sent new answer by mistake... ODBC access is programming connection from your software to SQLite. If you need DB manager for SQLite there is SQLite Expert.
Well thanks, but the biggest problem now is that when I try to add new ADO.NET database, I receive: Your project references the latest version of Entity Framework; however, an Entity Framework database provider compatible with this version could not be found for your data connection.
Do you know that you can delete this answer and add a comment where this belongs?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.