| | | 
StrataFrame 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? |
| | | | 
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 |
| | | | 
StrataFrame 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. |
| | | | 
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) |
| | | | 
StrataFrame User
       
Group: StrataFrame Users Last Login: 08/21/2008 11:49:01 AM Posts: 303, Visits: 435 |
| | | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 4:58:13 AM Posts: 4,379, Visits: 4,421 |
| No problem |
| |
|
|