Sharing a database connection


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
From what I can see, SF keeps a collection of Data Sources which are connections to the database that are available for use.  This is great for anything that has SF as its base in the application, which should be most things.  However, if there is some other third-party control that needs a database connection, or if I just wanted to directly access the open connection object in code how do I go about doing that?  Basically, I want to know how I can take an open db connection that SF has, and pass it to another object without it having to open up a new connection.
Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
There is also a method on the DbDataSourceItem object that creates new connections that can be used with the data source.

Dim loConnection As SqlConnection = DataLayer.DataSources("").CreateBlankDbConnection()

loConnection.Open()

'-- Do work

loConnection.Close()

You can also access a DbDataSourceItem from the DataSources collection by either key or by index.  Generally, you will want to use the key (string value) to retrieve the data source, as you never know what order the data sources are in.  If you only have one data source (generally you will), then you can access it fine by either DataSources("") or DataSources(0).

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