Why I get this error? Pls urgent

shomoodro

Member
Joined
Aug 25, 2005
Messages
14
Programming Experience
Beginner
How to solve the following error. It occurs when I try to open connection.

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in project2.exe

Additional information: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Thank you in advance

shomoodro
editpost.php?do=editpost&p=17619
 
thank you for the reply. I already solved the problem. But in an unexpected way. I wasn't catching exceptions. I guess for some reason (may be the database locks or something) it was throwing exception. I just added code to catch those exception and it is working fine with my code without changing anything else (I don't really know why). But it is good as long as it works.
 
Hi

After your message I tried to figure out what was really happening.

I set connection string at form load. But I found before loading form it loads tab control and other controls. In one of the tab pages I used database query. While loading tabpages it throws tabcontrol1.SelectedIndexChanged. So when the tab page is loading the connection string wasn't set yet. So it throws an exception. That was the reason why it was not running before.

Now I set the connection string at the start of the InitializeComponents(), it stopped throwing exception.

In 2005, there is a whole new file for Designer Generated Codes and I think they handled this matter properly so it doesn't throw any event while initializing or form loading
 
This scares me: System.Runtime.InteropServices.COMException

That tells me that you are probably using ADO classic aren't you?

Check my Sig... read the ADO.NET article.... in the long run, it'll be better to learn & use ADO.NET.

-tg
 
Back
Top