1,105,375 Community Members

Connection String in connected architecture.

Member Avatar
Rahul47
Posting Whiz
340 posts since Jan 2013
Reputation Points: 13 [?]
Q&As Helped to Solve: 20 [?]
Skill Endorsements: 2 [?]
 
0
 

Hello guys,

I am using connected architecture to develop an application.
For every form am designing there requires to put the connection string to connect to databse. Is there any way that If I change connection string at one point it is automatically changed at other.

Thanks

Member Avatar
Begginnerdev
Veteran Poster
1,142 posts since Apr 2010
Reputation Points: 251 [?]
Q&As Helped to Solve: 191 [?]
Skill Endorsements: 15 [?]
 
0
 

Declare the string in the application settings, then call that setting.

Example:

'In Application Settings

Name | Type |   Scope   | Value
myCon|String|Application|'Your Connection String Here

'In code
Dim con As New OleDBConnection(My.Settings.myCon)

If the string is changed in the application settings - it is changed globally.

Member Avatar
Rahul47
Posting Whiz
340 posts since Jan 2013
Reputation Points: 13 [?]
Q&As Helped to Solve: 20 [?]
Skill Endorsements: 2 [?]
 
0
 

@Begginnerdev: What if i use Type as Connection String ?
IN that Case it aint working !

Any Suggestions ??

Member Avatar
Begginnerdev
Veteran Poster
1,142 posts since Apr 2010
Reputation Points: 251 [?]
Q&As Helped to Solve: 191 [?]
Skill Endorsements: 15 [?]
 
0
 

Is this ConnectionString a Type, or are you refering the the SQLClient.ConnectionString property?

Member Avatar
Rahul47
Posting Whiz
340 posts since Jan 2013
Reputation Points: 13 [?]
Q&As Helped to Solve: 20 [?]
Skill Endorsements: 2 [?]
 
0
 

@Begginnerdev: ConnectionString is a type in settings of project.

Member Avatar
Begginnerdev
Veteran Poster
1,142 posts since Apr 2010
Reputation Points: 251 [?]
Q&As Helped to Solve: 191 [?]
Skill Endorsements: 15 [?]
 
0
 

I am assuming you are using a project data source?

Is this correct?

If so, what error/message are you getting when you change the connection string?

If not, where is the ConnectionString type coming from?

Is it a custom class/type/structure?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article