Retrieve Server and Database and Login information


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Actually there is an easier way if you do not want to parse it yourself.  You can pass the connection string into the SqlConnectionStringBuilder class and it will parse the string for you into properties:

Dim connInfo As New SqlClient.SqlConnectionStringBuilder(DataBasics.DataSources(0).ConnectionString)
Dim msg As String = ""


msg &= connInfo.DataSource & ControlChars.CrLf
msg &= connInfo.InitialCatalog & ControlChars.CrLf
msg &= connInfo.UserID & ControlChars.CrLf
msg &= connInfo.Password & ControlChars.CrLf
msg &= connInfo.IntegratedSecurity.ToString()
MsgBox(msg)

Greg's solution is always a good workaround though if this doesn't give you what you need.

Michael Reese
Michael Reese
Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Yeah, I was hoping that I would not have to go that route!

Thanks much!

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
The connection string is usually a set of key=value pairs, delimited by semi-colons. So, a bit of string manipulation will get you there. Just use the Split function on semi-colons first, then split on each pair on using '='. Either just test each as you go or you could add them to a dictionary, so you could then just access each value by its key.



Hope that makes sense! BigGrin
Michael Reese
Michael Reese
Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K

I can get the connectioninfo from;

MicroFour.StrataFrame.Data.DataLayer.DataSources.Item(0).ConnectionString.ToString

However, I How can I separedly retrieve the following from my SF project?

Server Name

Database Name

Server Login

Thanks

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