Question about connections


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm very new to this (using the trial edition, v1.5) and have a question about connections. I would like to connect to different databases (dev, test, prod, etc.) so the connection manager is very nice for this. However, I also would like to a single logon to the database, then use the security module to authenticate users, etc. and NOT have them authenticate directly against SQL Server.



I.e. I would like to use a normal web app like system, the app can connect, via a known, but secure username and password to SQL Server, the users authenticate against a table or Windows (less likely) to get access to the app. I would like to use this in both WinForm and WebForm apps.



I see that the Web sample is using the DataLayer.DataSources.Add, while the WinForms use ConnectionManager.AddRequiredDataSourceItem. What's the difference?



Also, what are your suggestions for storing the connection information (username, password especially) for a WinForm or WebForm app? How to change easily? Any way to allow users to change? (Mainly for testers).



Thanks!

Greg
StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The difference between the AddRequiredDataSourceItem and the DataSources.Add() is that the first is used by the connection manager to give enough information to gather the connection string and call DataSources.Add() internally, while the second just adds the data source manually without using the ConnectionManager at all. 

If you want to be able for all workstations to share a connection string, then you can use the Shared Settings File (I believe there is a document in the help explaining the workings of the Shared Settings File).  It allows you to centralize the connection without having to distribute the username/password to everyone. 

As for the webforms applications adding the connection manually through DataSources.Add(), this is required since you cannot use the Connection Manager because you can't show a Windows UI within a web app.

Your desire on the security is exactly what the security was designed for... to authenticate the users within the system after they connect to the database using a well known username & password.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks for the info. This is what I need.



I checked out the help file and have a better understanding of the ConnectionManager and Shared Settings. However, I'm still not quite getting it. Here are some more questions about it.



- I don't get how you can set the connection string for a specific workstation, as the help file describes. In the help file they say that they will use Windows authentication for all workstations except Station52, which will use a user/password as set in the shared settings file. Huh? I didn't see anything in the Shared Settings Wizard related to workstations. What's going on here?



- How is the connection information stored in the shared settings file related to my required data source items? I have two, one for application data and one for security. Obviously I would need to set the connection for both of these in the shared settings file, but the shared settings wizard only offered to save one connection and there was no description or name other than a file name.



- How do I indicate that a shared settings file is to be used? Is this done via code? The ConnectionManager? Can the user select which shared setting file (this seems to be indicated in the help file, I just can't figure it out)? Unsure



Thanks for your help. I'm sure this is easy stuff, once I get it!
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Huh? I didn't see anything in the Shared Settings Wizard related to workstations. What's going on here?

Ultimately all connections are stored locally.  So this means that each workstation is ultimately responsible for itself, so to speak.  For example, one workstation may not use the shared settings file and you could just manually enter the connection details.  You can also have more than one shared settings file, so different workstations may look at a certain shared settings file based on their tasks, etc.  As for setting a workstation within the shared settings file itself, you cannot do this.

How is the connection information stored in the shared settings file related to my required data source items?

This would require two shared settings files.  Shared settings files are associated with each individual required connection. 

How do I indicate that a shared settings file is to be used? Is this done via code? The ConnectionManager? Can the user select which shared setting file (this seems to be indicated in the help file, I just can't figure it out)?

The shared settings file will be provided when the Connection Wizard appears.  So this will require either the installer or the end-user to select this one time (the initial time the application is run).

But keep in mind that you do not have to use the default approach here.  We expose everything and you can even manually specify the connection strings if need be.  Ultimately all connection strings, whether specified manually or done through the Connection Wizard end up in the DataSources collection:

MicroFour.StrataFrame.Data.DataBasics.DataSources(0)

So there are a number of different ways to get your connection strings established.  But as far as the Shared Settings File, the only way to use it is through the Connection Wizard approach.

I hope this answers your questions.  Let me know if I need to be more clear.  Thanks. Smile

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
OK, it's making more sense. I guess the next thing I need to know is how to clear existing settings for an app, so I can test it. I.e. how do I clear the current settings so the connection manager appears? Also, is any of this related to the New Profile/Open Profile items on the File menu of the standard StrataFrame application (MDI)?



Thanks for your continued help! You folks have been great!
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
how do I clear the current settings so the connection manager appears?

Option 1
All of the connection settings are stored in an external encrypted file which you can just delete and when you re-run your application the wizard will automatially appear.  These files are located in the following location:

C:\Documents and Settings\All Users\Application Data\MicroFour\ConnectionData

There are two files, the AppKeys.dat and the Connections.dat.  If you delete these any StrataFrame application that uses the Connection String Wizard will automatically show the wizard the next time the app is run...just FYI this includes StrataFrame itself on your development machine since StrataFrame uses itself Smile

Option 2
Change your application key within the AppMain.vb or program.cs file depending upon your language.  You will find this in the SetDataSources() method.  Since all automated connection strings are stored using this application key as the unique identifier, changing this will force the wizard to re-appear since it will not be able to locate an active connection string for this key.

ConnectionManager.ApplicationKey = "ChangeThisValue"

Option 3
Probably your best bet on most occasions is to just edit the connection through the wizard.  This same editor allows you to have more than one set of connection strings per application.  For example, you can bounce between your development server, testing server, and production server without ever getting out of the application itself.  To show this window and add a new connection or edit an existing one, call the following method:

ConnectionManager.ShowAvailableConnectionStrings()

You can find more details on this in the docs, but this should get you going.

Also, is any of this related to the New Profile/Open Profile items on the File menu of the standard StrataFrame application (MDI)?

Yes, if you created a StrataFrame Main Form, this template already has the Database Connection menu item that basically performs the Option 3 specified above.

Thanks for your continued help! You folks have been great!

Thanks! Smile  We're glad to help.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
OK, thanks for the infor on clearing connections.



One last bit of clarification. What are the Open Profile/New Profile items in the File menu supposed to be used for? There is no code and there is already a Database Connection item.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Oh...you can just delete those or change the names to whatever you would like.  It is just there as a place marker and serves no purpose.  We just had those as menu items when we created the template...so you can disregard those...sorry for the confusion. 

Then only menu item that is functional in that template is the Database Connection...

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
OK, thanks for all the information. I'm sure you'll be hearing from me again. BigGrin
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Great Smile !  Feel free to post anytime!!!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search