Results 1 to 6 of 6

Thread: win form application does not run on another machine

  1. #1
    .NET Framework
    .NET 4.5
    Join Date
    Oct 2017
    Posts
    5
    Rep Power
    0

    Question win form application does not run on another machine

    hi
    i have a win form application written c# in Visual Studio 2017.
    it's a simple client registration form with Linq to SQL that uses a .mdf database file stored in the \bin\debug folder.
    while running the application on my own machine there is no problem, and it runs fine. but when i create a setup for it using publish command of the VS and installing it on another machine ( for instance the virtual machine installed on this laptop), it shows an error message that it could not connect to the database.
    this is the error message

  2. #2
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Posts
    1,981
    Rep Power
    154
    Did you actually read that error message? It tells you pretty much all you need to know. The data file is useless on its own without an appropriate SQL Server instance to be attached to.

  3. #3
    .NET Framework
    .NET 4.5
    Join Date
    Oct 2017
    Posts
    5
    Rep Power
    0

    Question

    Quote Originally Posted by jmcilhinney View Post
    Did you actually read that error message? It tells you pretty much all you need to know. The data file is useless on its own without an appropriate SQL Server instance to be attached to.
    i have MS SQL server 2012 Express LocalDB installed on this machine. but it does not work. that was the reason to post the problem.

  4. #4
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Posts
    1,981
    Rep Power
    154
    Then that is information that you should have provided in the first place. We only know what you tell us so you have to tell us everything that is relevant. If the error message says that the LocalDB instance doesn't exist then the inference is obvious.

    What version of SQL Server did you develop against? I wonder whether it's a version issue, as SQL Server databases have a compatibility level and higher-level databases can't attach to lower-level instances. I don't know whether you'd get a different error message in that case or not, but you can test that to find out.

  5. #5
    .NET Framework
    .NET 4.5
    Join Date
    Oct 2017
    Posts
    5
    Rep Power
    0
    Quote Originally Posted by jmcilhinney View Post
    Then that is information that you should have provided in the first place. We only know what you tell us so you have to tell us everything that is relevant. If the error message says that the LocalDB instance doesn't exist then the inference is obvious.

    What version of SQL Server did you develop against? I wonder whether it's a version issue, as SQL Server databases have a compatibility level and higher-level databases can't attach to lower-level instances. I don't know whether you'd get a different error message in that case or not, but you can test that to find out.
    my code in written in C# using MS Visual Studio 2017
    i have created this mdf database using visual studio itself (from server explorer i added a Data connection and selected "MS SQL server Database file" and saved that database file in \bin\Debug folder where the exe file exist. than i have made a table in it. i added a "Linq to sql class" added the table to that class. then in form load event i added the folowing code to show the data in a "data grid view":

    private LinqClassDataContext Context = new LinqClassDataContext();
    var AllData = from User in Context.Users select User;
    this.dataGridView1.DataSource = AllData;

    to answer to the question about the version of sql server i have some versions installed on my own machine that i use for programing that are all but the compact version is installed by visual studio.
    Capture.JPG
    also on the target machine i have installed sql server 2012 express localdb

  6. #6
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Posts
    1,981
    Rep Power
    154
    The version of LocalDB on your machine appears to be 2016 so it may well be a version issue. If you create a database in SQL Server Management Studio 2016 against a SQL Server 2016 instance then, unless you specify otherwise, it will not be compatible with an instance of any earlier version. It seems quite likely that the situation could be similar for LocalDB. I don't know that for a fact but I'd suggest that you try installing the 2016 version of LocalDB on that machine and see if it works then. I suspect that it will.

    You might also check the connection string being used because there might have been a change in format at some point between those version. That's a stab in the dark but it's worth checking out.

Similar Threads

  1. Replies: 1
    Last Post: 10-12-2017, 11:33 PM
  2. Nothing happens when I run my application after setup
    By UnderpaidIntern in forum Deployment
    Replies: 0
    Last Post: 04-17-2016, 11:15 PM
  3. Windows Form Application in Visual Studio 2010.
    By abc9873del in forum Projects for Hire
    Replies: 0
    Last Post: 11-25-2012, 10:20 PM
  4. Question Windows Form Application!
    By abc9873del in forum Projects for Hire
    Replies: 2
    Last Post: 11-25-2012, 10:03 PM
  5. Question code doesn`t work in win xp but works win 7 Pin
    By royk in forum C# General Discussion
    Replies: 0
    Last Post: 08-01-2012, 4:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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