StrataFrame Forum

Windows Service - Connection String

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

By Tim Dol - 11/8/2006

I have a windows service project which is going to be used for integration between two applications. How do I handle the connection string for my business objects in a non StrataFrame project.  I have a variable that contains the necessary connection string so how and where would I set the connection string?

Thanks,
Tim

By Trent L. Taylor - 11/8/2006

You will just manually add the connection to the data sources collection.  You can find the full help document in the StrataFrame Help: Application -> WinForms -> Connection Strings -> DataLayer.DataSources Collection.  But in short here is a code snippet:

MicroFour.StrataFrame.Data.Databasics.DataSources.Add(New SqlDataSourceItem("","MyConnectionString"))

By Tim Dol - 11/10/2006

I found this works fine if you execute it once but if you execute it twice a error is generated.  I found this code sample from the documentation, which I think will work for me, but it doesn't seem to exist.  Was it removed from the framework??

Example

   '-- Set the connection string manually    MicroFour.StrataFrame.Data.DataLayer.ConnectionString = _        "server=myserver;user id=sa;password=password
 
 
By Trent L. Taylor - 11/11/2006

This needs to be removed...this is no longer where the connection information is stored.  This was "old school" Smile  All you need to do it test if the connection already exists within the collection:

If MicroFour.StrataFrame.Data.DataBasics.DataSources.Count = 0
    '-- Add your connection
End If
By Tim Dol - 11/13/2006

Thanks Trent.  This took care of the problem.

Tim