Program works on local machine, but not on others [SQL Server localdb]

529 views Asked by At

I've been creating a local off-line program in c#, following tutorials and learning as I go. I learned to create SQL Server databases and connect to them through the model first tutorial on MSDN. My application is working at the moment but only on my computer.

I noticed this when I tried testing it on another laptop, without Visual Studio installed. The error that comes up reads

The underlying provider failed on Open

I'm not really sure why this is occurring and after researching this topic and reading several articles none of them have fixed it.

The SQL file was generated from an ADO.net model if that helps

The connection string as auto-generated by Visual Studio is as follows (formatted for readability):

data source              = (localdb)\v11.0;
initial catalog          = RandomInputMachine.logIn;
integrated security      = True;
MultipleActiveResultSets = True;
App                      = EntityFramework

SQL Server version is 2012

Specific code where error occurs:

// Display all users from the database 
var query = from b in db.Users1
            select b;

Console.WriteLine("All users in the database:");
foreach (var item in query)
{
    if (!deleteAll)
    {
        Console.WriteLine("---------------------------------------------------");
        if (item.username != "agentender" || Program.user == "OVERIDE")
        {
            Console.WriteLine(item.username);
        }
        if (item.username == txtUser.Text)
        {
            if (item.password == GetHashedString(txtPass.Text, item.salt))
            {
                Program.user = item.username;
                Program.loggedIn = true;
            }
        }
    } else {
        db.Users1.Remove(item);
    }
}

How can I work out what is wrong?

1

There are 1 answers

2
StarPilot On

The problem is one or more of the following:

  1. SQL Server is not installed on your test lap top.
  2. The database file is not found or not available at the current permission settings.
  3. You do not have permissions on the test lap top's SQL Server installation.
  4. The test lap top's SQL Server does not have a database named RandomInputMachine as you specify in your connection string.

SQL Server Express is free to install. It can be found at Microsoft SQL Server Express Edition home page