Can access SQL Database via SSMS, but not via VS2013 - visual-studio

I have an Azure database, SSMS 2012, and VS 2013. I have created the appropriate logins and users for myself and a colleague using the server login to access the Azure database. However, for reasons unknown to me, I can only access the database through SSMS. In VS I can access and login into the server just fine. But, when we click to expand the database, it produces and 'x' and denies showing any related tables, etc. Yet, from SSMS all is accessible with no problem. My colleague can access the database on his machine via SSMS or VS 2013 Community Edition. The problem seems to exist on only my machine and only with respect to the created logins. I can access the database fine using the admin credentials. I have attempted reinstalling VS, but it hasn't helped. Thoughts from anyone?

To Access Azure on your system with VS 2013
Very first please allow your IP in Azure SQL database firewall.
Connect Azure Subscription in Server explorer.
Go to SQL database and select your database and right click on that and select "Open in SQL Server Object explorer".
In SQL Server Object explorer your database will reopen with all required option and table list.

It turns out I cannot access the database because the Azure db I created is the 2014 (v12) version. I have SSMS 2012 (v11) loaded on my machine which is not compatible with the v12 db. Hence, the issues. The short of it is: I need to update to SSMS 2014 and reload VS afterwards since it partially relies on SSMS.

Related

Publish to Azure SQL from Visual Studio 2017 - Unable to connect

I recently set up an Azure SQL Database and server (using the free S0 trial). I've been able to log in to it using SQL Server Management Studio and create a couple users, and I've been able to log in as those users through SQL Server Management Studio. I'm also able to log in and manage the database from Visual Studio's Server Manager and SQL Server Object Explorer.
I have a SQL Database Project in my Visual Studio Solution for an app I'm working on. Using the same connection strings that I've been using in SSMS and VS's server manager, the Database Project is unable to publish to Azure, throwing the following error:
Unable to connect to master or target server '{Redacted}'.
You must have a user with the same password in master or target server '{Redacted}'.
My IP has been added to the firewall and is set to allow access. My username does not include the # sign, and I have tried with and without the #servername with no change. I also tried manually setting up the connection string, and copying/pasting the one in Azure (and populating the username and password).
I currently have the database project's Target Platform set to Microsoft Azure SQL Database V12, which matches what it reports the version as, although I have tried just Microsoft Azure SQL Database and SQL Server 2016.
Seeing as I'm able to connect from every other method I've tried so far, I assume there's something wonky in my publish profile or project that just doesn't stand out to me, or a bug in the publishing utility. Any ideas?
This is a known issue. This happens due to the new compatibility level 140 for newly created SQL Azure databases. The issue has been documented here and updating SSDT from here to the latest version may solve the issue.
Alternatively, you can change the compatibility level of your database to 130.
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = 130;
Hope this helps.

VS 2013 Setup Projects Works on one server and does not on another

We recently migrated from VS 2008 to VS 2013 including a set of setup projects. One of the setup projects is meant to install a web application. It has one custom action that is meant to check the connection to the database. The code of the custom action has not been touched during the migration and the .msi works perfectly when generated from VS 2008. When I built the .msi from VS 2013 it works perfectly well when installing on our local development server, and throw an error saying that it cannot connect to the db when rolling out in the clients environment.
I'd really appreciate if anyone can point me into direction of search here. I know that I'm passing a correct connection string, and .msi generated from VS 2008 can connect to that db from the same server.
Visual Studio custom actions that are installed for Everyone will run with the local system account. Connecting to a SQL DB will often fail because the DB doesn't allow the system account to connect, or because the DB is on a network share and the system account has no network privileges.
So it could fail because of the security settings of the DB or because the DB is on a network, and it may be nothing to do with the server. It might also connect if the install runs with a Just me setting because the custom actions then will run with the installing user's credentials. There may also be issues with architecture because servers are 64-bit and the 32-bit subsystem is optional, and you didn't say whether you install was x64 or your custom action code.

Can't add Local Database to project

This might be a really dumb question... but in VS2013 when trying to add a local database to my Windows Forms Application Project the option is now shown in the C# items menu. The only DB that is available is a Service-Based DB. From what I understand, this is related to SQL Compact Edition but I do have SQL Server 2012 installed. Any ideas? Or are there any significant differences between the Local DB and Service-Based DB?
A service-based database is a database that is only accessed through a server. It uses an MDF data file, which is SQL Server format. To be able to connect to a SQL Server database the SQL Server service must be running, because it's that that processes your requests and access the data file.
A local database is one that is local to your application only. It uses an SDF data file, which is SQL Server CE (Compact Edition) format. There is no need to install a server to access an SDF database. You simply distribute the DLLs that constitute SSCE along with your app and access the data file directly.
You'd normally only use SSCE if the data was to be accessed by your app only and there was a relatively small amount of data. For your project you would use SQL Server. For testing purposes you can use the free Express Edition. When deployed you might still use SSEE or you might use a full version of SQL Server. Note that Microsoft include SSEE with their own RMS POS software. SSEE is limited to databases of 4GB though, so even if you start out with SSEE and it can handle the load, you may still have to upgrade at some point in the future based on data capacity.
Source of info:jmcilhinney post.
for help on creating the database have a look at this tutorial it may be of some help.
Hope this info helps you :)
It turns out VS2013 dropped the .sdf format.
Is Microsoft dropping support for SDF database files in Visual Studio?
The answer is yes: Microsoft is silently dropping support (as usual IMHO) to Sql Compact Edition.
It started abandoning Sql CE 3.5 in Vs2012 It continued dropping Sql CE in Sql Management Studio 2012 and finally in VS2013
You can use CompactView or install SQL Server Compact Toolbox extension in VS2013 or (my prefered solution) use Sql management Studio 2008
UPDATE thanks to Nicolas' comment
As stated by Microsoft:
SQL Server compact edition is in deprecation mode with no new releases planned near future. Last release SQL CE 4.0SP1 (and earlier releases that are still in the support cycle) will continue to be supported through its lifecycle and Microsoft is committed to fix any major, production blocking issues found in these releases.
Have you tried adding your local database from inside the project? Have a look and see if you can add your database from datasources.

Connecting to end user's SQL Express during installation

I have been writing SQL Compact C# winforms applications for a while now, with the help from all the wizards in Visual Studio. The database is created during development, and installed as-is. Then suddenly, I realise I actually have no clue how to connect to SQL Express on client's machine and install a database if I had to.
There are many examples on connection string and creating database in SQL Express via code (C# in my case) but I don't think that is what I am looking for.
If I develop an application that requires SQL Express. I know there's a feature in Visual Studio that detects and install SQL Express if it does not exist. However, how do I set up and install my database in SQL Express? Do I need to somehow get credentials somewhere?
You mention both SQL Server Compact Edition and SQL Server Express Edition; these are two different things, but for the case you've described you probably mean SQL Server Compact Edition.
SQL Server CE comes with the .Net Framework, so no install should be required. However, you will have to create a database. You can do that with SqlCeEngine.CreateDatabase().
EDIT
For SQL Server Express... to get a connection string from the user without them having to actually type in a connection string, you can use a data connection dialog: archive.msdn.microsoft.com/Connection

Install a SQL Server database to a client's machine

I need to install a SQL Server 2008 database on several user machines. The users are not technically proficient, so I cannot create a script and just give it to them. I need to be able to create an executable that will create the database. The executable will check if the user has SQL Server 2008 Express installed, then install the database. The executable will install the database using Integrated Security, so I don't need the user's id or password.
I tried using the database project in Visual Studio 2010, but it just creates scripts.
Is there an open source solution to creating an executable that installs SQL Server databases?
May I suggest that you look at embedding SQLServer 2008 Express within your application.
Check the Microsoft link here.
Then you can check for an SQL instance and install one if it doesn't exist when the program first starts up.
A simple way would be to use SQL Server Management Objects (SMO) to create a .NET console application that creates the database.
Depending on your security rights on your user's machines you may be able to run the app from your workstation and deploy directly to their machines.
SMO can also be driven by powershell.

Resources