StrataFrame Forum

Connection Wizard appearing

http://forum.strataframe.net/Topic16342.aspx

By Ross L. Rooker, Sr. - 5/12/2008

In the sample as soon as the statement: StrataFrameApplication.RunApplication();  executes, if the connection info is not found, the connection wizard appears. The project I am working on, the client wants to suppress the wizard from appearing but bring up a form to tell the user to contact the administrator. Is there a way to intercept the logic before the connection wizard displays.

The sample I am referencing is in the program.cs in the security sample.

StrataFrameApplication.ShowLoginAndInitializeForm +=

new StrataFrameApplication.ShowLoginAndInitializeFormEventHandler(

ShowLoginAndInitMainForm);

//-- Run the application

StrataFrameApplication.RunApplication();

 

By Ross L. Rooker, Sr. - 5/12/2008

To further clarify when the Application Run occurs the method SetDataSources() executes first and the command: ConnectionManager.SetConnections(); executes. If the connection is not found, that is when the Database Connection Wizard form appears. My question is whether I could test the result before the Connection Wizard appears and then decide whether to go ahead and display the Connection Wizard or to bring up a form informing the user that they need to contact their administrator.
By Greg McGuffey - 5/12/2008

SetConnections() does not return any thing, so I don't think you can change this. I.e. SetConnections() will show the wizard if the connections aren't found in the cached connection file on the user's machine.



Which means that either they would have to use the wizard at least once OR you would have to distribute this file.



There are other ways, however. Most of the time you'll actually manage the connection yourself, using the DataLayer.DataSources() collection. This allows you lots of flexibility in how you set the connection. You might search the forum for this, as there are some excellent posts on how this can be done.



Hope that helps!
By Trent L. Taylor - 5/13/2008

SetConnections just lines it all up for you.  You can just call the GetActiveConnection strings and manually set the connection. 

If ConnectionManager.GetApplicationActiveConnectionString("MyKey", "").Length > 0 Then
    '-- You have an active connection
End If

Once you have the connection string you can just manually add it to the datasources collection:

MicroFOur.StrataFrame.Data.Databasics.DataSources.Add(New SqlDbDataSourceItem("",MyConnectionString)