Visual Studio Adding Data Connections - Given Key not Present in the Dictionary - sql

I've read through a couple of previous similar questions and none seem to provide a fix.
so i ask again.
I'm using Visual Studio and am trying to connect to a DB in Server Explorer. Regardless of what database i try to connect to it gives a "Given Key not Present in the Dictionary" error.
i have tried with SQL CE and SQL Express 2008 databases and each give the same issue.
I can connect quite easily with SQL Management Studio Express so i believe the Databases are the same.
Thanks in Advance.

after a lot of time searching for the answer to this i found the solution here
this is not really a workaround but in fact a SOLUTION, how to get rid of the error, in case you have missed to remove all connections before removing the provider:
edit C:\Users...\AppData\Roaming\Microsoft\VisualStudio\10.0\ServerExplorer\DefaultView.SEView and remove the connection with the wrong Provider manually. If you do not know which of the provider is failing, simply delete the file :)
If this won't help try deleting also C:\Users...\AppData\Local\Microsoft\VisualStudio\10.0
PS: you have to quit all instances of visual studios first or the files will be re-created from memory ..
The second part only worked for me , deleting the whole folder.

I had recently installed the MySQL Connector, and had multiple instances of Visual Studio open. After shutting them all down, I was able to add a connection to the Server Explorer.
Adding to what BastanteCaro said, I had open the DefaultView.SEView file in case I needed to go down that path. When I shut everything down and started up a new instance of Visual Studio, Notepad++ reported that the file had changed. So either there was an uncommitted change to the file or some sort of cleanup/addition was made on startup.

Related

How do I deploy the data to the %programdata% directory when compiling a executebal in vb.net

I created.exe file and installed it on my machine.When I insert data I get an error "Failed to update database "Database.mdf" because database file is read-only". I am able to view the data but cannot insert the data. I am using local sql database and visual studio 2019. My connection string is:
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\HovedDatabase.mdf;Integrated Security=True
I have read a lot of topics on the forum about this and so fare I have changed the settings to the db in the SSMS, so that it is not longer a permisson issue.
But it still gives the same error. One thing I havent tried, because of lack of skill, is deploying the data to the %programdata% directory. It looks like this advice is given regarding this issue. So anybody have a idea on how to do this in Visual Studio. I am pretty new to this so dont be afraid to give detailed instructions :) Thank you in advance :)

Visual Studio 2013 SQL Query and View Designer not appearing

Not sure why the Query and View Designer is not appearing as per
http://msdn.microsoft.com/en-us/library/vstudio/ms172013.aspx
It's an ASP.net project with database in the AppData folder, and a connection using SQL 2008 Express.
If it helps the connection string is:
Data Source=.\SQLEXPRESS;AttachDbFilename="C:\folders...\App_Data\database.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
If I open the project in VS2012 (where I've worked on this project for some time), find a table, right click, new query, I get the nice interactive visual design tool.
If I open the project in VS2013 (just installed) and do the same, blank page named SQLQuery1.sql and a basic connection to SQL Express (ie. master, model, etc.)
MS page tells me Tools / Options / Visual Database tools - but this doesn't exist on my installation!
Am I missing something?
Also tried with blank project, added App_Data and a new database (so using LocalDB), added a table, right click, new query - exactly the same blank file.
I have been having the same problem and think I have found the solution.
When you are adding the connection to the Database, in the Add Connection Dialog.
Click 'Change...' next to the Data source
Dialog opens showing 'Change Data Source'
You probable have selected 'Microsoft SQL Server' and then below that there is a drop down where you can select:
.NET Framework Data Provider for OLE DB
.NET Framework Data Provider for SQL Server (This is probably selected by default)
try changing to the OLE DB connection.
Click OK, and then complete the rest of the connection on the 'Add Connection' dialog.
I have then found that using the database works as it did in VS2012 and as you are describing above.
Was searching for a solution to a similar issue. Unable to use Query Designer for a local mdf file database. This is what I found...hope it helps someone.
Reading the comments here (http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed4675d3-aa84-47db-bdf5-f852355409e6/query-designer-not-displaying-in-visual-studio-2013?forum=ssdt).
According to the moderator of that forum question (Kevin Cunnane of Microsoft), "in Visual Studio 2013 the query designer and database diagram features are no longer available from the Server Explorer. If you wish to keep using the query designer, the only other workaround for now is to access it from SSMS. "
My current workaround is to use Visual Studio 2012 Server Explorer to view data and write queries for a local MDF file. And to use Visual Studio 2013 for everything else.
I have researched about 5 minutes how to run a query in Visual Studio. At the end I found this:
Even though i followed same steps , It did not work at once it gave some error and Studio closed. It was problem at my end and unknowingly it got sorted out on its own.
This component is called "SQL Server Data Tools". You can download it from MSDN. I found this page simply by googling "vs2013 ssdt". It seems that what TsugaSoft posted is true, however you still can install this component separetely... And it also works for Visual Studio 2012.

Visual Studio SQL Server Object Explorer Not Saving Connections

I'm using Visual Studio 2012 for development. I really like using the SQL Server Object Explorer to work on database related tasks (queries, schema changes etc.). The issue is, every time I reload the IDE, I have to connect to the databases I work with. Is there a way to persist the list of databases like I can with the Server Explorer tab?
When you say you can't replicate, how long have you been using the explorer for to attempt to replicate it? It only loses the connections every now and then, so in fact right now I can't replicate it either, but over the next few days I'm sure they will get reset again!
It seems that there is something wrong with your VS IDE
It seems that this is a little bit unlikely as the same thing happened to me when I was running in VS 2012 beta running on Win 8 Release Preview too.
However I will try your suggestions and i'll see what happens, just to clarify are you saying that I run those commands once and then after that use VS as usual or are you saying that I try running in safe mode all the time?
Is reset settings same as the Import and Export settings->Reset All Settings menu item? (By the way I run with general development settings)
Anyone know where these connection settings are actually stored (registry, folder ...)?
Open VS. DonĀ“t open any project or solution.
Add your databases in the Server Explorer.
Then File -> Save All

SQL Server Management Studio 2012 hangs

When I click on the "Databases" node in "Object Explorer" it just keeps on "Loading items" until at some point it just hangs.
This happens only when connecting to a remote server, not when accessing a database on my PC.
It also doesn't happen with any other node.
The guys at the web-hosting company didn't have any trouble with it. (But they're running 2008, and so is the SQL server there)
I reinstalled the whole SQL server etc. but to no avail.
What might be the problem?
I experienced this same problem: when accessing a remote server with the Object Explorer, SSMS would hang indefinitely. The Windows System Event Log would show DCOM error 10009 ("DCOM was unable to communicate with the computer MACHINE_NAME using any of the configured protocols.").
The solution was to clear the MRU history and other settings from my profile. To do that:
Close any open instances of SSMS 2012
In Explorer, open "%AppData%\Microsoft\SQL Server Management Studio"
Rename the "11.0" folder to something else, like "11.0.old"
Open SSMS 2012
You'll see that your MRU list has been cleared. You should then be able to re-enter your credentials and use SSMS as normal.
If everything works, you can delete the renamed folder. Otherwise, delete the new "11.0" folder that was created and rename the original one back to "11.0".
I have no idea whether it's actually the MRU list that's causing this problem or if it's some other profile data.
We were able to discover that SSMS is trying to make a DCOM connection over port 135 to the SQL Server (perhaps for SSIS, T-SQL Debugging, or something else). Our firewall was configured to block port 135. By opening the port in the firewall we were able to use SSMS (hence the reason it worked against local databases but not remote ones). Unfortunately, an open port 135 is an invitation for a lot of attacks, so that wasn't a practical solution for us.
Turn Auto-Close off on all the databases. Worked like a charm to me!
Every time you expand or refresh the database list, server has to awake the databases causing the hang.
Just run this to find all the databases that have auto-close on
SELECT name, is_auto_close_on
FROM master.sys.databases AS dtb
WHERE is_auto_close_on = 1
ORDER BY name
Credits to http://social.msdn.microsoft.com/Forums/sqlserver/en-US/99bbcb47-d4b5-4ec0-9e91-b1a23a655844/ssms-2012-extremely-slow-expanding-databases?forum=sqltools
To turn-off this setting for a database - Right click on database instance in object explorer -> Click properties -> Click "Options" in left navigation pane in database properties window -> Change the value of Auto Close property to "False" in right pane as shown in the snapshot below:
Assuming you have access to only one database at the hosting company (which is almost always the case, at least with a certain username/password), you can avoid the need to use the dropdown at all by setting your registered server to default to the database you're supposed to access:
(It may take longer here, too, but this will be one-time. You can also type it instead of waiting for the list to populate.)
This way, even if the login the host created for you routes you to tempdb or something by default, Management Studio will still put you in the context of your database.
I see now that you are talking about the Object Explorer node, not the "Use database" dropdown that I somehow interpreted incorrectly. An exercise to try might be to highlight the databases node (don't expand it) and click on F7 (Object Explorer Details). If this loads for you then it can be an alternative to navigate through the hierarchy and, as a bonus, you can show lots of entity attributes here and also multi-select, two things you have no control over in Object Explorer.
If that doesn't help, then your host should be helping you better than they appear to be. If SSMS 2012 is supported then they should be able to test this in SSMS 2012 and confirm or deny that they can reproduce it. If it is not supported then I think your recourse is to install SSMS 2008 as well (they can co-exist) and use it for managing this specific server.
Of course, just about anything that you can do in Object Explorer (and plenty of things you can't), you can do by using the catalog views and/or DMVs. So before you determine what to do, you may want to review (or share with us) exactly what you are using Object Explorer for - if there is a way to do it without Object Explorer, you might like the workaround better than having two versions of the tool (since the improvements in 2012 SSMS have absolutely nothing to do with Object Explorer).
In my case deleting the profile folder worked exactly once. The next time I opened SSMS 2012 it would freeze again when connecting to a server. SP1 didn't fix this either.
That was until I found the following simple workaround described on a ticket by Ben Amada over at connect.microsoft.com: Always close the Object Explorer Details before closing SSMS 2012.
So the complete workaround for me is this:
Follow Jaecen's answer, but close SSMS 2012 again after it created a clean profile folder
Apply Hoodlum's recommendation and copy SqlStudio.bin from the old profile folder to the new one (the old profile folder can be deleted afterwards)
Everytime before closing SSMS 2012 make sure the Object Explorer Details window is closed
The first two steps are required only once, or if the Object Explorer Details window was left open accidentally.
Edit
I just noticed that closing the Object Explorer Details window is also required when (re-)connecting to an SQL server in the same SSMS session. So basically whenever connecting to a server the Object Explorer Details windows has to be closed.
I spent over a month with Microsoft SQL Support troubleshooting this. It has been submitted as a bug.
I have both SQL 2012 SSMS and VS 2012 installed on Win 7 (64).
Deleting the profile folder never worked for any reasonable length of time.
The workaround we found was to ensure that my SSMS profile defaulted to the Master database when connecting. It appeared to have something to do with the fact that I'm connecting with Windows Authentication and I belong to more than one AD group that have SQL permissions assigned AND I don't have SQL specific permissions set up on my AD account.
I am connecting to several remote servers rangig from 2000 to 2012.
SMSS on local PC is SQL Server 2012,SMSS is 11.0.2100.60
SSMS freezes several times a day.When this occurs, I go via RDP to the
local server / SMSS / Activity Monitor and kill the processes from my PC with Database Name = master, one at a time, until SMSS on my PC unfreezes.
This always works, however, a cure for the disease raher than the symptoms would be highly welcome.
Have some SQL Servers from 2000 to 2012,
access then through SMSS from my desktop.
Problem occurs with varying frequency, looks like this: when I collapse a server in object explorer, SMSS freezes.
looking in activity monitor on the server in question, i find a process in master db with host = my desktop executing the following query
SELECT dtb.name AS [Name] FROM master.dbo.sysdatabases AS dtb ORDER BY [Name] ASC SMSS
killing the process frees SMSS.
Here is what worked for me
Open SSMS
click on connect to object explorer button
in the connect to server dialog box expand options >>
click reset all
Done!
I've test approximately all above answers but my SSMS got stuck in expanding the database list. I found the problem finally. The problem was because of a database that I restored it but It did restore correctly at the end. Then When I expanded the database list it was sticking.
I run a the query
SELECT
dtb.name AS [Name]
,dtb.database_id AS [ID]
,CAST(has_dbaccess(dtb.name) AS bit) AS [IsAccessible] FROM master.sys.databases AS dtb
Then the result took too long and at the end timed out but When I filter the stuck database I got result.
SELECT
dtb.name AS [Name]
,dtb.database_id AS [ID]
,CAST(has_dbaccess(dtb.name) AS bit) AS [IsAccessible] FROM
master.sys.databases AS dtb
Where name <> 'StuckDB' ORDER BY [Name] ASC
At the end I decided to detach StuckDB to solve my problem.
I have now applied SQL 2012 Service Pack 1 (through Windows Update) and it seems to work fine now, though it does take a very long time to load.
"Open SSMS click on connect to object explorer button in the connect to server dialog box expand options >> click reset all" - it works
I solved this problem by changing my default database back to master.
Go to database properties at SSMS and change compatibility to 2012. Then check.

Editing SQL query with Visual Studio 2008

Would you recommend me the best approach to edit SQL query with Visual Studio 2008 Professional, please?
I know I can open Query window from context menu in Server Explorer and edit text in SQL Pane. But unfortunately I am not allowed to save query to a file and Find and Replace commands are not working there.
Alternatively I can open text file with extension .SQL in Visual Studio editor obtaining syntax highlighting and full editing capabilities but losing possibility to execute the script.
Now I copy query text from one window to another and back but I hope there is better solution.
Many thanks for suggestions!
When I have to connect to Sql Server, I use NetBeans, as it has a number of features that make it much easier to use than Visual Studio. One of these is intellisense, which is very useful when you have an alias for a table name and lots of long field names. The general handling of connections and connection pools is also much cleaner in NetBeans. I could go on, but suggest trying it for yourself. You will almost certainly need the Sql Server jdbc driver, which can be downloaded from http://msdn.microsoft.com/en-us/data/aa937724.aspx
If you create a Database project within your solution in Visual Studio, then you can set up a default database connection for that project. Then any *.sql files that are included in the database project can be executed against that connection. What I usually do is select the text to be exectued and right-click it, then select "Run Selection".
You can set up any number of database connections under the "Database References" node in the solution explorer, and choose the one you want to run your query against.
Wow you are right, this is a real pain. Would it be acceptable for you to use a local copy of the SQL Management Studio (the name might be wrong)? You would be outside of VS but you could still edit your query and run it at the same time. Definitely not optimal but better than nothing.
Good luck.