StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Getting the provider typeExpand / Collapse
Author
Message
Posted 07/20/2006 3:32:25 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
How do I get the provider type from the data source?  I would like to know whether I am looking at a SQL, Oracle, DB2, etc. database.  Also, is there any way other than parsing the connection string to get out the Server, Database Name, User ID, and Password? 
Post #1901
Posted 07/20/2006 3:57:53 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
There are several options.  You can test on the data source type to determine which provider is being used based on the type of object which would probably be the easiest.

Dim loType As System.Type = MicroFour.StrataFrame.Data.DataBasics.DataSources.Item("").GetType()

        If loType Is GetType(MicroFour.StrataFrame.Data.SqlDataSourceItem) Then
            MsgBox("SQL Server")
        ElseIf loType Is GetType(MicroFour.StrataFrame.Data.OracleDataSourceItem) Then
            MsgBox("Oracle")
        ElseIf loType Is GetType(MicroFour.StrataFrame.Data.VfpDataSourceItem) Then
            MsgBox("VFP")
        ElseIf loType Is GetType(MicroFour.StrataFrame.Data.AccessDataSourceItem) Then
            MsgBox("Access")
        End If

 

Post #1902
Posted 07/20/2006 4:56:09 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
Ok, that works for getting the type.  Is there any way to get the other information I referred to like Database Name, User ID, Password, and Server?  I can parse the connection string, but this seems a little unreliable.
Post #1904
Posted 07/20/2006 4:59:40 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
Once you determine the type, use a ConnectionStringBuilder, pass it the connection string, and it will parse it for you.

Dim loConn As New System.Data.SqlClient.SqlConnectionStringBuilder(MicroFour.StrataFrame.Data.DataBasics.DataSources(0).ConnectionString)

        MsgBox(loConn.DataSource)
        MsgBox(loConn.UserID)
        MsgBox(loConn.Password)

Post #1905
Posted 07/20/2006 5:04:43 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
Great!  thanks.
Post #1906
Posted 07/21/2006 9:14:10 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
No problem
Post #1909
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 7:24pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.125. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.