PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] Application won't run on a fresh windows installation.-VBForums
Results 1 to 11 of 11

Thread: [RESOLVED] Application won't run on a fresh windows installation.

  1. #1

    Thread Starter
    Lively Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    76

    Resolved [RESOLVED] Application won't run on a fresh windows installation.

    Hello!

    I'm having problems trying to run an application I developed in VS 2019, I created an .msi installer file and it used to work just fine, but then... I reformatted my PC, installed my application ... and now it won't run. it shows this message.

    Name:  Error.PNG
Views: 80
Size:  103.4 KB

    Do I have to install Visual Studio and SQL Server all over again in order to run my Application?

    this program is supposed to work on any computer, I don't think the End-Users have to install Visual Studio & SQL Server packages to run the application.

    Thank You.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,845

    Re: Application won't run on a fresh windows installation.

    You don't have to install Visual Studio. It's a development environment for creating applications. It's not required to run those applications though. If that was the case then you'd have to install every development environment anyone ever used to create any of the applications installed on your system. That would be ridiculous, right?

    SQL Server is a different matter. It is a database server and, without the server, how can you possibly access a SQL Server database? MDF files just contain data, not a means to access that data. It's the database server that attaches the data file and enables you to read and write to it. If your connection string specifies a SQL Server instance to connect to and no such instance exists, why would you expect it to work? If you didn't want your application to rely on SQL Server then you shouldn't have used a SQL Server database. There are options for file-based databases that won't require anything else to be installed, including Access MDB files (not ACCDB files, which do require the Access engine to be installed) and SQLite. If you use SQL Server then you need SQL Server.

    That said, SQL Server Express is free and you can configure your installer to install it automatically.

  3. #3

    Thread Starter
    Lively Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    76

    Re: Application won't run on a fresh windows installation.

    Hey! Thank you for your feedback!

    When I started to build this solution, I had no idea SQL databases are dependent on a server, I just created my DataBase
    within VS... thinking it'll work on any computer! (LOL), now I'm scared because I will have to change every single query through out my solution (I'm talking about 150 queries) Which I guess they require different syntax and name spaces. As you may have already noticed ... I'm a newbie in programming, in fact when I started the project, I didn't know anything about programming, but watching youtube tutorials, reading and asking from forums I finally finish this project, and now that is done, I realized in won't work as I expected. but That's fine! I keep learning from failure, sooner or later I'll make it work right so I can share it.

    Thank you for your support, and I'm going to fix it, perhaps slowly but I won't give up.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,845

    Re: Application won't run on a fresh windows installation.

    Quote Originally Posted by Spybot View Post
    now I'm scared because I will have to change every single query through out my solution (I'm talking about 150 queries) Which I guess they require different syntax and name spaces.
    What you need to change depends on exactly what you have done. As an example, if you want to change from SQL Server to Access then it is quite possible that nearly all you'll need to do is change from using objects in the SqlClient namespace to the OleDb namespace, e.g. use an OleDbConnection, OleDbCommand and OleDbDataAdapter instead of a SqlConnection, SqlCommand and SqlDataAdapter. You can change the imported namespace at the project level and then use Find & Replace to change the classes. The SQL code may stay exactly as it is, but there may also be certain things that need changing. You would also have to change your connection string.

  5. #5
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,062

    Re: Application won't run on a fresh windows installation.

    There is also the LocalDB option of SQL Server Express, which is even lighter weight and meant for use only on a local PC (e.g., can't be used from a network share apparently like an Access MDB can).

    Changing the namespace and objects is the easy part.

    If you go with SQL Server Express or its LocalDB option, you shouldn't have to change any SQL. You will likely need to make a few tweaks if you go with Access or SQLite as their syntax doesn't always correlate to what the SQL Server family supports. Once you find one such instance, just do a find for any other places you used it and repeat as needed until it all works again.

    I have to say I'm impressed that a newbie has taken on such a large project. I'm not sure I have any single project in my 3 decades that has 150 SQL queries.

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,845

    Re: Application won't run on a fresh windows installation.

    Quote Originally Posted by topshot View Post
    There is also the LocalDB option of SQL Server Express, which is even lighter weight and meant for use only on a local PC (e.g., can't be used from a network share apparently like an Access MDB can).
    It doesn't necessarily mean that you can't use it elsewhere but LocalDB is intended specifically for developers.

  7. #7

    Thread Starter
    Lively Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    76

    Re: Application won't run on a fresh windows installation.

    Hi jmcilhinney!

    Doing some research I found whats it looks to be a possible solution for my problem... this is supposed to work on VS 2010 I'm in VS 2019. what do you think?

    Since C:\PROGRAM FILES and C:\PROGRAM FILES (x86) are configured by the operating system (for security reasons), to block write operations.
    So, the recommended folder for writing application wide data (settings or database data files) can be retrieved by calling Environment.GetSpecialFolder using the parameter CommonApplicationData of Environment.SpecialFolder enum.

    STEPS:
    1.- Right click on the File System, select Add a Special Folder and then Custom folder
    2.- Give a name to the new folder in the File System Tree
    3.- Set the property DefaultLocation to [CommonAppDataFolder]
    4.- Create a sub-folder for your application right-clicking on the new added folder [Custom Folder].
    5.- Use this folder to add your database file.

    After this, change your application ConnectionString and point it to the new location of the file. In C# you write something like this

    C# Code:
    1. string commonData = ENvironment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
    2. string pathToDBFile = Path.Combine(commonData, "MyAppDir", "MyDB.sqlite");

    OK...

    Trying to replicate these steps... I got stock on number (3), my VS 2019 is lacking the option for [CommonAppDataFolder] instead I have these:
    Name:  Capture.jpg
Views: 30
Size:  30.8 KB
    then the connection string shown above is written in C#, how would it look in VB.NET?

  8. #8
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,062

    Re: Application won't run on a fresh windows installation.

    Quote Originally Posted by Spybot View Post
    Trying to replicate these steps... I got stock on number (3), my VS 2019 is lacking the option for [CommonAppDataFolder] instead I have these:
    So did you try typing it in? Make sure you include the brackets.

    then the connection string shown above is written in C#, how would it look in VB.NET?
    Simple string assignments should have been easy enough to figure out, but if you get stuck on conversions in the future, there are several converters out there to give you a decent push.

  9. #9

    Thread Starter
    Lively Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    76

    Re: Application won't run on a fresh windows installation.

    Hi topshot!

    Thanks for your feedback, I didn't know converters exist, now I can translate C# code to VB.NET

    Also, the DefaultLocation property for [CommonAppDataFolder], I never imagined it could be edited manually, since it is a property option, but now I know it.

    I've finished all the steps, except for this one: Where am I supposed to insert this code?

    VB.NET Code:
    1. Private Sub SurroundingSub()
    2.     Dim commonData As String = ENvironment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
    3.     Dim pathToDBFile As String = Path.Combine(commonData, "MyAppDir", "MyDB.sqlite")
    4. End Sub

  10. #10
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,062

    Re: Application won't run on a fresh windows installation.

    Quote Originally Posted by Spybot View Post
    Where am I supposed to insert this code?
    If you know where you need to know the path to the db file you'll answer your own question.

    FWIW, I keep my SQLite db local to the exe folder so I use this:
    Code:
           Public conData As New SQLiteConnection
    
            conData.ConnectionString = "Data Source=" & My.Application.Info.DirectoryPath & "\data.s3db;Version=3;"
            Try
                conData.Open()
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try
    In reality the connection string in my case could be just "Data Source=data.s3db;Version=3;"

  11. #11

    Thread Starter
    Lively Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    76

    Re: Application won't run on a fresh windows installation.

    Hello!

    OK ,I finally make it work! using the following connection string:
    "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Personal_Folder\Owner_db.mdf;Integrated Security=True;Connect Timeout=30"

    All I was missing... was installing the "SQL Server Express 2016," in order to have a server and a user instance, this... I didn't understand at the beginning. Now it runs on any machine as long as SQL Server Express 2016 is installed.

    Thank you all for all your feedback!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width