locked
Unable to add data connection. Key not valid for use in specified state.

    Question

  • Using Visual Studio 2005, I am no longer able to add data connections to my projects.

    After testing the connection to an existing database and clicking OK, I get the 2-line message "Unable to add data connection. Key not valid for use in specified state."

    I am able to work with the databases using sqlcmd and SQL Server Express Manager.

    Thursday, August 11, 2005 2:07 AM

Answers

  • I found a relevant bug report (FDBK18994) in
    http://lab.msdn.microsoft.com/productfeedback/default.aspx
    the MSDN Product Feedback Center.

    I solved the problem by renaming the VisualStudio folders in
    ..\Application Data\Microsoft
    ..\Local Settings\Application Data\Microsoft
    to VisualStudioXXX

    I had installed Visual Studio Team System (after I got the CD-ROMs in the mail) on top the express editions of Visual C# and Visual Web Developer. I did not experience any problems for several weeks. After renaming the two directories, I have a cleaner looking GUI that has Team Explorer and Class View tabs. I even have File-New-Project. Now I understand why the labs and webcasts have looked different from my version.

    Thursday, August 11, 2005 11:03 PM

All replies

  • Have you checked the VS 2005 Beta site to see if this bug has been reported, or has a workaround
    Thursday, August 11, 2005 2:45 PM
  • I found a relevant bug report (FDBK18994) in
    http://lab.msdn.microsoft.com/productfeedback/default.aspx
    the MSDN Product Feedback Center.

    I solved the problem by renaming the VisualStudio folders in
    ..\Application Data\Microsoft
    ..\Local Settings\Application Data\Microsoft
    to VisualStudioXXX

    I had installed Visual Studio Team System (after I got the CD-ROMs in the mail) on top the express editions of Visual C# and Visual Web Developer. I did not experience any problems for several weeks. After renaming the two directories, I have a cleaner looking GUI that has Team Explorer and Class View tabs. I even have File-New-Project. Now I understand why the labs and webcasts have looked different from my version.

    Thursday, August 11, 2005 11:03 PM
  • This fix is temporary for me.  Every time I log off and back on, the problem reoccurs.  My work-around is to delete the data connections and rebuild them.

    Kevin
    Wednesday, August 17, 2005 8:38 PM
  • This solution worked for me.

    1. Open the registry

    2. Rename [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0]

    To [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0back]

    3. Restart Visual Studio

     

     

    Ali

     

    Friday, July 07, 2006 12:02 AM
  • After encountering this error, I deleted all unused datasources, some of which didn't work. This seemed to of done the trick.

    Therefore, delete any DataSources that do not work.

    Kurt
    Monday, January 15, 2007 8:48 AM
  • hey Ali,

    If you could explain me what you did. That would be helpful.


    Im still getting the same error.   """Key not valid for use in specified state"""

    And i checked and deleted all the datasource. But still when i try to add a datasource it again shows me the same message.      my email id is  hiten@nit-me.com.

    Thanks pal
    Wednesday, July 04, 2007 10:46 AM
  • I have the same thing, Not modified the data sources for ages, now a user wants an item adding to the database so I was about to modify to use the new item and voila.

     

    Nothing works I have removed all the data sources (shows no data sources at all) and I have tried to add a data source and got the same message every time.

     

    I cannot see any other method around this, does MS expect you to completely rewrite the application to get around this?????.

    Tuesday, July 24, 2007 2:37 PM
  • I have the same issue.  Very frustrating!!

     

    I have tonnes of code to rewrite if I cannot fix this bug!! Please help!  Please do not suggest re-installing VS2005.

     

    Monday, September 24, 2007 10:37 PM
  •  

    I ran into to this this AM as well.  I had to change my password this morning and when I changed it back to the old one all worked fine.  We still have a NT domain not AD.  Anyway hope this helps.

     

    Bruce

    Monday, October 15, 2007 7:05 PM
  • Sunday, we changed our domain name, (parent company deemed we fit under thier domain)  So I promo'd our server and removed our domain and then promo'd  it back to their domain.  when I changed my computer to the new domain, I found all of the programs which ran perfect on the old domain, now would not even start.  I figured maybe just go in and change the datasource to reflect the new domain.  When I tried to access any data function, I get a pop up "Unable to add data connection. Key not valid for  use in specified state."  Nothing mentioned prior in this string have worked.  HELP!!! 

     

    Tuesday, January 08, 2008 8:56 PM
  •  

    Even after three installs of visual studio and Sql server, no help.  I erased the hard drive and re-installed windows, then vs then sql and all works.  A very sad way to have to do something, but.  On the server I had yet more fun from the domain change.   All is now working.
    Thursday, January 17, 2008 6:04 PM
  • After changing my Windows logon password all data-connections in VS2005 were broken.
    New data-connections were not possible.
    SQL-server and VS2005 are both running on the machine were the password was changed.

    The method Kurt found works for me.
     
    Wednesday, February 20, 2008 11:50 AM
  • At the risk of sounding like a broken record, I am having this issue also. I have uninstalled and reinstalled VS2005 twice.

    I have reinstalled SQL2005 express twice.

    I have tried Ali's registry fix which did not work.

    I started a new project. There are no datasources (used or unused) to delete so Kurt's solution doesn't work.

    I have officially ran out of ideas.

    Any more ideas?

     

    Vahid

    Thursday, March 13, 2008 7:45 PM
  • Sad indeed! One should not have to reinstall Windows to solve a problem like that.

     

    Thursday, March 13, 2008 7:49 PM
  • I wish also, but I tried and tried and just the domain name change forced me to reinstall windows, plus everything writen and compiled in VS, had to be stripped from the bin files. basically everything except the source code.  Then everything that was in an incrypted directory was totally lost.  I hate domain name changes. 

    Friday, March 14, 2008 12:52 AM
  • hi

     

    When u open a new project in VS2005, there is some datasources available that may not be connected. so Open in Server Explorer in VS, and see if there is any Datasource that is not connected , first delete it. then u can try to add a new connection.

    I tried it , It works..

     

     

    Dev

    Wednesday, July 16, 2008 10:16 AM
  • Your post is CORRECT. This does resolve the problem. Thank you.

     

    Friday, July 25, 2008 8:20 AM
  • Thanks,

    This worked for me too. But how does this work??
    Thursday, September 11, 2008 6:21 PM
  • when i got this error, i tried to connect to my data connection in server explorer but was unable to, so i deleted it. i recreated a connection and everything works fine.

     

    After reading these threads, i realized my password was forcibly changed this morning on my AD domain. even if i changed my pwd back to the old one, the sql connection was broken. however, doing what Dev said worked for me too.

     

    Monday, September 15, 2008 5:49 PM
  • I really thought this thread was dead, I have been up since my last post.  Here is what I did:

     

    First I completely reinstalled windows (just r & r VS2005 does not work, keys are hidden somewhere same problem comes up and it will not compile any programs) once I had a fresh install of windows, I installed VS2005.  Then I took all the source code from my programs and re-compiled them and installed them to the server.  It has run perfect for several months now. 

     

    I lost an intire day fighting microsoft's stupid anti-piracy junk, that is redoing the pc and all 22 programs;  but that is the price we are stuck with, because some people just cannot go out and pay for software.  I have banged code for over 23 years and I cannot stand a thief!

     

    Mike

    Tuesday, September 16, 2008 5:39 PM
  • Cool! This works great. First I tried with Registry changing per Ali and this didn't work. Next, I renamed  Visual Studio\8.0 under my profile as mentioned by Glenn and it worked. Thanks Glenn.

     

    Guys, I will tell you for sure, you don't have to reinstall VS 2005 at all. I think this will work for majority of the people's problem with regards to this particular issue. ALL THE BEST.

    Tuesday, October 14, 2008 8:30 PM
  • I ran into this problem about 3 years ago and still haven't gotten it resolved. I don't have the option of re-installing the operation system, only VS2005. I bought 2 versions, Professional and VSTools for office. Installing both was the root of the problem. I really wish that some one from Microsoft would give a better solution than installing the operating system again. There must be something left over when VS2005 is uninstalled. Perhaps a registry key. I tried changing the key as previously posted, it didn't work.

    Thursday, October 23, 2008 9:41 PM
  • Thanks! This worked for me too!

     

    -David

     

    Monday, October 27, 2008 8:41 PM