views:

326

answers:

1

I have a form with an OleDbConnection object on it. This form fails to load in the Form Designer with the message:

One or more errors encountered while loading the designer. 
The errors are listed below. Some errors can be fixed by rebuilding your project, 
while others may require code changes.

Invalid authorization specification 
   at ADODB.ConnectionClass.Open(String ConnectionString, String UserID, String Password, Int32 Options)
   ... (stack trace continues into user code)

I've tracked this down to the OleDbConnection string. If I hardcode in the server IP, username/password/dbinstance into the constructor of the GUI form then the form will load in the designer. At run-time it is not an issue because we require the user to provide the login details.

The question:

Is it possible to use the OleDbConnection and the Form designer without supplying the database credentials in the source code of the form? For example, is there a property of the OleDbConnection or Form that I can set so that it doesn't need to access the database during Form design?

My concern is that if we ever move the database server or change the login that the code will stop working in the designer.

A: 

After even more debugging, I see that the problem is actually with an ADODB.Connection object.

Dim adoConn As New ADODB.Connection()
adoConn.ConnectionString = MyProject.GetConnStr()
adoConn.Open() ' This line throws the exception

If I have the above code in the constructor or the Load event then it cannot be opened in the Form Designer (I get the error "invalid authorization specification"). For now I'm looking for a way to move this bit of initialization code to a place that it still gets called consistently but is not found by the Form designer.

Jason Dagit