Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Design-time error E_UNEXPECTED trying to connect to Access database
 

Design-time error E_UNEXPECTED trying to connect to Access database

I have a winforms app using typed dataset, and it runs just fine, but I can no longer use the designer in visual studio on most of the forms or the dataset itself. I get the oh-so-helpful error "Failed to open a connection to the database. No error message available, result code: E_UNEXPECTED (0x8000FFFF)"

I think it must be failing to find the |DataDirectory| location at design-time, even though it can find it at run-time. I try using the wizard to create a new connection, and clicking the Test Connection button raises the same error.

I'm using Access, and the .accdb file is copied properly into bin/Debug. I can open it directly from there no problem. Also, the application runs fine, so it can obviously make the connection when it matters. Still, I would like to be able to configure the queries from the dataset.xsd view and I would like to be able to view the forms in design mode. Any suggestions?

Thanks in advance!

shefehs  Tuesday, September 29, 2009 3:05 PM
remove the database statements which you have added from the InitializeComponent() function and place it in constructor or on form_load() event .. in InitializeComponent() function only auto generated code should be there if u try to add your own code you may experience this problem..
Bharath kumar Y.S  Wednesday, September 30, 2009 6:27 AM

Hi shefehs,

Please follow Bharath’s suggestion to move the code to the constructor or Load event handler at first. Then check the DesignMode property to only execute the code in runtime as follows:
if (!DesignMode)

{

//Write code about database operations here.

}

Let me know if this does not help.
Aland Li

Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Thursday, October 01, 2009 6:50 AM
remove the database statements which you have added from the InitializeComponent() function and place it in constructor or on form_load() event .. in InitializeComponent() function only auto generated code should be there if u try to add your own code you may experience this problem..
Bharath kumar Y.S  Wednesday, September 30, 2009 6:27 AM

Hi shefehs,

Please follow Bharath’s suggestion to move the code to the constructor or Load event handler at first. Then check the DesignMode property to only execute the code in runtime as follows:
if (!DesignMode)

{

//Write code about database operations here.

}

Let me know if this does not help.
Aland Li

Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Thursday, October 01, 2009 6:50 AM

You can use google to search for other answers

Custom Search

More Threads

• No alpha-channel images (PNG) in tab page headers
• I can't find the AutoSize in the Properties
• UserControl(ContainerControl) Receiving Focus
• Insufficient memory to continue the execution of the program.
• Passing Values between multiple forms
• How to stop designer adding columns when i build the project
• Change Location at design time problem
• my project lost "handles" clause for a ton of controls...anyone else had this happen?
• child controls of custom control disappear at run-time
• Implement the calculator logic